Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: client/bin/base_utils.py

Issue 1317002: Continue to refactor autoserv to build client test at run time. (Closed)
Patch Set: path 18 Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/bin/autotest ('k') | client/bin/setup_job.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """ 1 """
2 DO NOT import this file directly - import client/bin/utils.py, 2 DO NOT import this file directly - import client/bin/utils.py,
3 which will mix this in 3 which will mix this in
4 4
5 Convenience functions for use by tests or whomever. 5 Convenience functions for use by tests or whomever.
6 6
7 Note that this file is mixed in by utils.py - note very carefully the 7 Note that this file is mixed in by utils.py - note very carefully the
8 precedence order defined there 8 precedence order defined there
9 """ 9 """
10 import os, shutil, sys, signal, commands, pickle, glob, statvfs 10 import os, shutil, sys, signal, commands, pickle, glob, statvfs
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return run_cmd('%s %s | %s' % (cat, file, command), 56 return run_cmd('%s %s | %s' % (cat, file, command),
57 ignore_status=ignore_status) 57 ignore_status=ignore_status)
58 58
59 59
60 def extract_tarball_to_dir(tarball, dir): 60 def extract_tarball_to_dir(tarball, dir):
61 """ 61 """
62 Extract a tarball to a specified directory name instead of whatever 62 Extract a tarball to a specified directory name instead of whatever
63 the top level of a tarball is - useful for versioned directory names, etc 63 the top level of a tarball is - useful for versioned directory names, etc
64 """ 64 """
65 if os.path.exists(dir): 65 if os.path.exists(dir):
66 raise NameError, 'target %s already exists' % dir 66 if os.path.isdir(dir):
67 shutil.rmtree(dir)
68 else:
69 os.remove(dir)
67 pwd = os.getcwd() 70 pwd = os.getcwd()
68 os.chdir(os.path.dirname(os.path.abspath(dir))) 71 os.chdir(os.path.dirname(os.path.abspath(dir)))
69 newdir = extract_tarball(tarball) 72 newdir = extract_tarball(tarball)
70 os.rename(newdir, dir) 73 os.rename(newdir, dir)
71 os.chdir(pwd) 74 os.chdir(pwd)
72 75
73 76
74 def extract_tarball(tarball): 77 def extract_tarball(tarball):
75 """Returns the directory extracted by the tarball.""" 78 """Returns the directory extracted by the tarball."""
76 extracted = cat_file_to_cmd(tarball, 'tar xvf - 2>/dev/null', 79 extracted = cat_file_to_cmd(tarball, 'tar xvf - 2>/dev/null',
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 Suspend the system to RAM (S3) 773 Suspend the system to RAM (S3)
771 """ 774 """
772 set_power_state('mem') 775 set_power_state('mem')
773 776
774 777
775 def suspend_to_disk(): 778 def suspend_to_disk():
776 """ 779 """
777 Suspend the system to disk (S4) 780 Suspend the system to disk (S4)
778 """ 781 """
779 set_power_state('disk') 782 set_power_state('disk')
OLDNEW
« no previous file with comments | « client/bin/autotest ('k') | client/bin/setup_job.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698