How to use put_file method in avocado

Best Python code snippet using avocado_python

AmazonEC2Manager.py

Source:AmazonEC2Manager.py Github

copy

Full Screen

...140 # Create the directory to hold our source141 print sshClient.run("mkdir ScarecrowTaskQueue")142 print sshClient.run("mkdir ScarecrowTaskQueue/EC2")143 # Copy our boto config144 print sshClient.put_file(common.EC2_LOCAL_BOTO_CFG_PATH, r"ScarecrowTaskQueue/boto.cfg")145 print sshClient.run_pty("sudo mv ScarecrowTaskQueue/boto.cfg /etc/boto.cfg").recv(2048)146 # Upload the source147 sshClient.put_file(r"EC2/__init__.py", r"ScarecrowTaskQueue/EC2/__init__.py")148 sshClient.put_file(r"EC2/EC2JobsDaemon.py", "ScarecrowTaskQueue/EC2/EC2JobsDaemon.py")149 sshClient.put_file(r"EC2/launch.py", "ScarecrowTaskQueue/EC2/launch.py")150 sshClient.put_file(r"__init__.py", r"ScarecrowTaskQueue/__init__.py")151 sshClient.put_file(r"AmazonETManager.py", r"ScarecrowTaskQueue/AmazonETManager.py")152 sshClient.put_file(r"AmazonS3Manager.py", r"ScarecrowTaskQueue/AmazonS3Manager.py")153 sshClient.put_file(r"AmazonSQSManager.py", r"ScarecrowTaskQueue/AmazonSQSManager.py")154 sshClient.put_file(r"AmazonSQSMessage.py", r"ScarecrowTaskQueue/AmazonSQSMessage.py")155 sshClient.put_file(r"ArchiveJobMessage.py", r"ScarecrowTaskQueue/ArchiveJobMessage.py")156 sshClient.put_file(r"ArchiveJob.py", r"ScarecrowTaskQueue/ArchiveJob.py")157 sshClient.put_file(r"WatermarkJobMessage.py", r"ScarecrowTaskQueue/WatermarkJobMessage.py")158 sshClient.put_file(r"WatermarkJob.py", r"ScarecrowTaskQueue/WatermarkJob.py")159 sshClient.put_file(r"TranscodeJobMessage.py", r"ScarecrowTaskQueue/TranscodeJobMessage.py")160 sshClient.put_file(r"TranscodeJob.py", r"ScarecrowTaskQueue/TranscodeJob.py")161 sshClient.put_file(r"Job.py", r"ScarecrowTaskQueue/Job.py")162 sshClient.put_file(r"JobManager.py", r"ScarecrowTaskQueue/JobManager.py")163 sshClient.put_file(r"ResponseMessage.py", r"ScarecrowTaskQueue/ResponseMessage.py")164 sshClient.put_file(r"ResponseManager.py", r"ScarecrowTaskQueue/ResponseManager.py")165 sshClient.put_file(r"common.py", r"ScarecrowTaskQueue/common.py")166 # Run the program167 print "Running EC2 daemon..."168 # print sshClient.run_pty("python ScarecrowTaskQueue/EC2/launch.py &").recv(2048)169 #print sshClient.run("python ScarecrowTaskQueue/EC2/launch.py > /dev/null 2>&1 &")...

Full Screen

Full Screen

idgen.py

Source:idgen.py Github

copy

Full Screen

...30 def put(self, key, data):31 if not key:32 key = self.hashfunc(data).hexdigest()33 return self._dstore.put(key, data)34 def put_file(self, key, file):35 bufsize = 1024 * 102436 phash = self.hashfunc()37 if not key:38 if isinstance(file, str):39 with open(file, 'rb') as source:40 while True:41 buf = source.read(bufsize)42 phash.update(buf)43 if len(buf) < bufsize:44 break45 return self._dstore.put_file(46 phash.hexdigest(),47 file)48 else:49 tmpfile = tempfile.NamedTemporaryFile(delete=False)50 try:51 while True:52 buf = file.read(bufsize)53 phash.update(buf)54 tmpfile.write(buf)55 if len(buf) < bufsize:56 break57 tmpfile.close()58 return self._dstore.put_file(59 phash.hexdigest(),60 tmpfile.name61 )62 finally:63 try:64 os.unlink(tmpfile.name)65 except OSError, e:66 if 2 == e.errno:67 pass # file already gone68 else:69 raise70 return self._dstore.put_file(key, file)71class UUIDDecorator(StoreDecorator):72 """UUID generating decorator73 Overrides :func:`put` and :func:`put_file`. If a key of *None* is passed,74 a new UUID will be generated as the key. The attribute `uuidfunc`75 determines which UUID-function to use and defaults to 'uuid1'.76 .. note::77 There seems to be a bug in the uuid module that prevents initializing78 `uuidfunc` too early. For that reason, it is a string that will be79 looked up using :func:`getattr` on the :mod:`uuid` module.80 """81 uuidfunc = 'uuid1' # for strange reasons, this needs to be looked up82 # as late as possible83 def put(self, key, data):84 if not key:85 key = str(getattr(uuid, self.uuidfunc)())86 return self._dstore.put(key, data)87 def put_file(self, key, file):88 if not key:89 key = str(getattr(uuid, self.uuidfunc)())...

Full Screen

Full Screen

PutFileCommand.py

Source:PutFileCommand.py Github

copy

Full Screen

...29 elif re.match(rf"^(PUT_FILE HELP)$", command):30 self._writeline(str(self.help))31 self._writeline('OK')32 elif self._storage.check_path(str(name)) is False:33 self._storage.put_file(str(name))34 self._writeline('OK')35 elif self._storage.check_path(str(name)) is True:36 self._writeline(f'ERROR: "{name}" is already exists.')37 else:38 self._writeline(f'Unknown: "{command}".')39 # if self._storage.check_path(name):40 # self._storage.put_file(name)41 # self._writeline(f'Файл {name} добавлен.')42 # else:43 # self._writeline(f'Файл {name} уже существует.')44 except (TypeError, ValueError) as error:...

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 avocado 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