How to use _psput_file method in fMBT

Best Python code snippet using fMBT_python

pycosh.py

Source:pycosh.py Github

copy

Full Screen

...722 _g_pspycosh_conn.close()723 _g_pspycosh_conn = None724 return "".join(rv)725 return ""726def _psput_file(conn, src_filename, dst_filename):727 data = file(src_filename, "rb").read()728 conn.eval_('file(%s, "wb").write(base64.b64decode(%s))' %729 (repr(dst_filename),730 repr(base64.b64encode(data))))731def _psput_dir(conn, dirname, dest_dir):732 rv = []733 dirname = dirname.replace("\\", "/")734 dir_dest_dir = dest_dir.replace("\\", "/") + "/" + os.path.basename(dirname)735 for root, dirs, files in os.walk(dirname):736 file_src_dir = root.replace('\\', '/')737 if file_src_dir[len(dirname):]:738 file_dest_dir = (dir_dest_dir + "/" + file_src_dir[len(dirname):])739 else:740 file_dest_dir = dir_dest_dir741 try:742 conn.eval_('os.makedirs(%r)' % (file_dest_dir,))743 except:744 pass745 for f in files:746 _psput_file(conn,747 file_src_dir + "/" + f,748 file_dest_dir + "/" + f)749 rv.append(file_src_dir + "/" + f)750 return rv751def psput(psconn, pattern):752 """psput CONNSPEC[//DEST] FILE...753 upload files to pythonshare server"""754 # Examples:755 # Put files to current working directory on host:756 # psput passwd@host:port files757 # Put localdir under cwd/relative/path on host:758 # psput passwd@host:port//relative/path localdir759 # Put localdir under /abs/path on host on Linux host:760 # psput passwd@host:port///abs/path localdir761 # Put localdir under c:/abs/winpath on Windows host:762 # psput passwd@host:port//c:/abs/winpath localdir763 # Put localdir to /abs/path on Linux host via hub/namespace:764 # psput passwd@hub:port/namespace///abs/path localdir765 # Check cwd on host:766 # pspycosh passwd@host:port pwd767 if isinstance(psconn, pythonshare.client.Connection):768 dest_dir = "."769 conn = psconn770 close_connection = False771 else:772 if "//" in psconn:773 psconn, dest_dir = psconn.split("//", 1)774 else:775 dest_dir = "."776 conn = pythonshare.connect(psconn)777 close_connection = True778 conn.exec_("import base64, os")779 rv = []780 for filename in expand(pattern, accept_pipe=False).splitlines():781 if os.path.isdir(filename):782 rv.extend(_psput_dir(conn, filename, dest_dir))783 else:784 _psput_file(conn, filename, dest_dir + "/" + os.path.basename(filename))785 rv.append(filename)786 if close_connection:787 conn.close()788 return "\n".join(rv)789def psget(psconn, pattern):790 """psget CONNSPEC FILE...791 download files from pythonshare server"""792 # Get *.txt from host to current working directory:793 # psget passwd@host:port *.txt794 # Get * from host via hub to current working directory:795 # psget passwd@hub/host *796 # Get * from HOSTDIR on host, via hub, to current working directory:797 # psget passwd@hub/host//HOSTDIR *798 if isinstance(psconn, pythonshare.client.Connection):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful