本文整理汇总了Python中sh.tar方法的典型用法代码示例。如果您正苦于以下问题:Python sh.tar方法的具体用法?Python sh.tar怎么用?Python sh.tar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sh
的用法示例。
在下文中一共展示了sh.tar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_stress
# 需要导入模块: import sh [as 别名]
# 或者: from sh import tar [as 别名]
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}
示例2: retrieve_logs_and_create_tarball
# 需要导入模块: import sh [as 别名]
# 或者: from sh import tar [as 别名]
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)
示例3: versions
# 需要导入模块: import sh [as 别名]
# 或者: from sh import tar [as 别名]
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
示例4: extract_versions
# 需要导入模块: import sh [as 别名]
# 或者: from sh import tar [as 别名]
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)