Python sh.tar() Examples
The following are 4
code examples of sh.tar().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sh
, or try the search function
.
Example #1
Source File: benchmark.py From cstar_perf with Apache License 2.0 | 6 votes |
def build_stress(stress_revision, name=None): # Build a stress revision try: git_id = sh.git('--git-dir={home}/fab/cassandra.git' .format(home=HOME), 'rev-parse', stress_revision).strip() except sh.ErrorReturnCode: raise AssertionError('Invalid stress_revision: {}'.format(stress_revision)) path = os.path.join(CASSANDRA_STRESS_PATH, git_id) if not os.path.exists(path): logger.info("Building cassandra-stress '{}' in '{}'.".format(stress_revision, path)) os.makedirs(path) sh.tar( sh.git("--git-dir={home}/fab/cassandra.git".format(home=HOME), "archive", git_id), 'x', '-C', path ) antcmd('-Dbasedir={}'.format(path), '-f', '{}/build.xml'.format(path), 'realclean', 'jar', _env={"JAVA_TOOL_OPTIONS": "-Dfile.encoding=UTF8", "JAVA_HOME": JAVA_HOME}) name = name if name else stress_revision return {name: git_id}
Example #2
Source File: benchmark.py From cstar_perf with Apache License 2.0 | 5 votes |
def retrieve_logs_and_create_tarball(job_id): log_dir = os.path.join(CSTAR_PERF_LOGS_DIR, job_id) if not os.path.exists(log_dir): os.makedirs(log_dir) retrieve_logs(log_dir) # Tar them for archiving: subprocess.Popen(shlex.split('tar cfvz {id}.tar.gz {id}'.format(id=job_id)), cwd=CSTAR_PERF_LOGS_DIR).communicate() shutil.rmtree(log_dir)
Example #3
Source File: utils.py From ansible-tools with Apache License 2.0 | 5 votes |
def versions(self): rr = requests.get(self.RELEASES_URL) soup = BeautifulSoup(rr.text, features='html.parser') hrefs = soup.findAll('a') hrefs = [x.attrs['href'] for x in hrefs] hrefs = [x for x in hrefs if x.endswith('.gz')] hrefs = [x for x in hrefs if 'latest' not in x] hrefs = [x.replace('.tar.gz', '') for x in hrefs] hrefs.append('ansible-devel') return hrefs
Example #4
Source File: utils.py From ansible-tools with Apache License 2.0 | 5 votes |
def extract_versions(self, version=None): tarballs = glob.glob('%s/tars/*.gz' % self.cachedir) if version: tarballs = [x for x in tarballs if version in x] for tarball in tarballs: dst = os.path.join( self.extractdir, os.path.basename(tarball).replace('.tar.gz', '') ) if not os.path.exists(dst): # extract to temp dir first to avoid clobbering temp_dst = dst + '.tmp' if os.path.exists(temp_dst): shutil.rmtree(temp_dst) os.makedirs(temp_dst) logger.debug('tar xzf %s -C %s' % (tarball, temp_dst)) try: res = tar('xzf', tarball, '-C', temp_dst) except Exception as e: logger.error(e) sys.exit(1) # what was the extracted root path? edirs = glob.glob('%s/*' % temp_dst) srcdir = edirs[0] # move the extract to the right place shutil.move(srcdir, dst) shutil.rmtree(temp_dst)