def testGetWithDir(self): tmpdir = utils.get_tmp_dir() origpath = os.path.join(tmpdir, 'testGetWithDir') os.mkdir(origpath) dstpath = utils.get(origpath) self.assertTrue(dstpath.endswith('/')) self.assertTrue(os.path.isdir(dstpath))
def testGetWithHTTP(self): # Yeah, this test is a bad idea, oh well url = 'http://www.kernel.org/pub/linux/kernel/README' tmppath = utils.get(url) f = file(tmppath) f.readline() self.assertTrue('Linux' in f.readline().split())
def testGetWithOpenFile(self): tmpdir = utils.get_tmp_dir() tmppath = os.path.join(tmpdir, 'testfile') tmpfile = file(tmppath, 'w') print >> tmpfile, 'Test string' tmpfile.close() tmpfile = file(tmppath) newtmppath = utils.get(tmpfile) self.assertEqual(file(newtmppath).read(), 'Test string\n')
def get(self, location): """ Get the source material required to install the object. Through the utils.get() function, the argument passed will be saved in a temporary location on the LocalHost. That location is saved in the source_material attribute. Args: location: the path to the source material. This path may be of any type that the utils.get() function will accept. """ self.source_material= utils.get(location)
def get(self, location): """ Get the source material required to install the object. Through the utils.get() function, the argument passed will be saved in a temporary location on the LocalHost. That location is saved in the source_material attribute. Args: location: the path to the source material. This path may be of any type that the utils.get() function will accept. """ self.source_material = utils.get(location)
def _do_run(self, control_file, results_dir, host, atrun, timeout, client_disconnect_timeout): try: atrun.verify_machine() except: logging.error("Verify failed on %s. Reinstalling autotest", host.hostname) self.install(host) atrun.verify_machine() debug = os.path.join(results_dir, 'debug') try: os.makedirs(debug) except Exception: pass delete_file_list = [ atrun.remote_control_file, atrun.remote_control_state, atrun.manual_control_file, atrun.manual_control_state ] cmd = ';'.join('rm -f ' + control for control in delete_file_list) host.run(cmd, ignore_status=True) tmppath = utils.get(control_file) # build up the initialization prologue for the control file prologue_lines = [] # Add the additional user arguments prologue_lines.append("args = %r\n" % self.job.args) # If the packaging system is being used, add the repository list. repos = None try: repos = self.get_fetch_location() pkgmgr = packages.PackageManager('autotest', hostname=host.hostname, repo_urls=repos) prologue_lines.append('job.add_repository(%s)\n' % repos) except global_config.ConfigError, e: # If repos is defined packaging is enabled so log the error if repos: logging.error(e)
def _do_run(self, control_file, results_dir, host, atrun, timeout, client_disconnect_timeout): try: atrun.verify_machine() except: logging.error("Verify failed on %s. Reinstalling autotest", host.hostname) self.install(host) atrun.verify_machine() debug = os.path.join(results_dir, 'debug') try: os.makedirs(debug) except Exception: pass delete_file_list = [atrun.remote_control_file, atrun.remote_control_state, atrun.manual_control_file, atrun.manual_control_state] cmd = ';'.join('rm -f ' + control for control in delete_file_list) host.run(cmd, ignore_status=True) tmppath = utils.get(control_file) # build up the initialization prologue for the control file prologue_lines = [] # Add the additional user arguments prologue_lines.append("args = %r\n" % self.job.args) # If the packaging system is being used, add the repository list. repos = None try: repos = self.get_fetch_location() pkgmgr = packages.PackageManager('autotest', hostname=host.hostname, repo_urls=repos) prologue_lines.append('job.add_repository(%s)\n' % repos) except SettingsError, e: # If repos is defined packaging is enabled so log the error if repos: logging.error(e)
def testGetWithString(self): path = utils.get('/tmp loves rabbits!') self.assertTrue(file(path).readline().startswith('/tmp loves'))
def testGetWithPath(self): path = utils.get('/proc/cpuinfo') self.assertTrue(file(path).readline().startswith('processor'))