本文整理汇总了Python中sh.touch函数的典型用法代码示例。如果您正苦于以下问题:Python touch函数的具体用法?Python touch怎么用?Python touch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了touch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execution_handler
def execution_handler(*args, **kwargs):
client = utils.Handler()
client.rmdir(TEST_DIR)
client.mkdir(TEST_DIR)
sh.touch(TEST_FILE)
func(*args, **kwargs)
client.rmdir(TEST_DIR)
示例2: _startup
def _startup(self):
self.debug("Using {} as startup config file".format(self.startup_config))
if not os.path.exists(self.startup_config):
self.debug("{} doesn't exist. Creating it")
sh.touch(self.startup_config)
self._scrub_extra_dotfiles_block()
self._add_extra_dotfiles_block()
示例3: test_console_script
def test_console_script(cli):
TEST_COMBINATIONS = (
# quote_mode, var_name, var_value, expected_result
("always", "HELLO", "WORLD", 'HELLO="WORLD"\n'),
("never", "HELLO", "WORLD", 'HELLO=WORLD\n'),
("auto", "HELLO", "WORLD", 'HELLO=WORLD\n'),
("auto", "HELLO", "HELLO WORLD", 'HELLO="HELLO WORLD"\n'),
)
with cli.isolated_filesystem():
for quote_mode, variable, value, expected_result in TEST_COMBINATIONS:
sh.touch(dotenv_path)
sh.dotenv('-f', dotenv_path, '-q', quote_mode, 'set', variable, value)
output = sh.cat(dotenv_path)
assert output == expected_result
sh.rm(dotenv_path)
# should fail for not existing file
result = cli.invoke(dotenv.cli.set, ['my_key', 'my_value'])
assert result.exit_code != 0
# should fail for not existing file
result = cli.invoke(dotenv.cli.get, ['my_key'])
assert result.exit_code != 0
# should fail for not existing file
result = cli.invoke(dotenv.cli.list, [])
assert result.exit_code != 0
示例4: ensure_syncer_dir
def ensure_syncer_dir():
if path.isdir(syncer_dir):
return
username = input('GitHub username: ')
password = getpass.getpass('GitHub password: ')
repo_exists = github.check_repo_exists(username, SYNCER_REPO_NAME)
if not repo_exists:
print("Creating new repo in GitHub")
github.create_public_repo(username, password, SYNCER_REPO_NAME)
print("Cloning GitHub repo.")
sh.git('clone', 'https://%s:%[email protected]/%s/%s.git' % (username, password, username, SYNCER_REPO_NAME), syncer_dir)
needs_commit = False
sh.cd(syncer_dir)
if not path.isfile(path('manifest.json')):
sh.touch('manifest.json')
if not path.isdir(path('content')):
sh.mkdir('content')
if not path.isdir(path('backup')):
sh.mkdir('backup')
if not path.isfile(path('.gitignore')):
needs_commit = True
with open('.gitignore', 'w') as gitignore_file:
gitignore_file.write('backup')
if needs_commit:
sh.git('add', '-A')
sh.git('commit', '-m', 'Setting up scaffolding.')
示例5: _create_simple_commit
def _create_simple_commit(self, message):
""" Creates a simple commit with an empty test file.
:param message: Commit message for the commit. """
test_filename = "test-file-" + str(uuid4())
touch(test_filename, _cwd=self.tmp_git_repo)
git("add", test_filename, _cwd=self.tmp_git_repo)
git("commit", "-m", message, _cwd=self.tmp_git_repo)
示例6: test_default_path
def test_default_path(cli):
with cli.isolated_filesystem():
sh.touch(dotenv_path)
sh.cd(here)
sh.dotenv('set', 'HELLO', 'WORLD')
output = sh.dotenv('get', 'HELLO')
assert output == 'HELLO="WORLD"\n'
sh.rm(dotenv_path)
示例7: test_default_path
def test_default_path(tmp_path):
sh.cd(str(tmp_path))
sh.touch(tmp_path / '.env')
sh.dotenv('set', 'HELLO', 'WORLD')
result = sh.dotenv('get', 'HELLO')
assert result == 'HELLO=WORLD\n'
示例8: test__run__reboot_success
def test__run__reboot_success(self):
"""
run: reboot success
"""
fname = "%s/../rebooting" % dirpath
sh.touch(fname)
self.bundle.run()
self.assertEqual(False, os.path.isfile(fname))
示例9: test__run__reboot_failed
def test__run__reboot_failed(self):
"""
run: reboot failed
"""
fname = "%s/../reboot-failed" % dirpath
sh.touch(fname)
self.bundle.run()
self.assertEqual(False, os.path.isfile(fname))
示例10: test_doc
def test_doc():
with cd('../../doc'):
project.build()
touch('_build/.nojekyll')
d = git('--no-pager', 'diff', '-w', '--', '_build')
if d:
print(d)
raise ValueError('Diffs in website')
示例11: setUpClass
def setUpClass(cls):
# Do back-up the existing corpus...
assert not os.path.exists(TEST_LOCK_FILE)
shutil.move(UC_HOME, UC_HOME_BACKUP)
# Recreate the test directory.
os.mkdir(UC_HOME)
touch(TEST_LOCK_FILE)
示例12: create_playbook
def create_playbook(books, play="site.yml"):
for book in books:
mkdir(book)
mkdir(book + "/host_vars")
mkdir(book + "/group_vars")
mkdir(book + "/roles")
touch(book + "/" + play)
touch(book + "/" + "README.md")
示例13: _create_simple_commit
def _create_simple_commit(self, message, out=None):
""" Creates a simple commit with an empty test file.
:param message: Commit message for the commit. """
test_filename = "test-file-" + str(uuid4())
touch(test_filename, _cwd=self.tmp_git_repo)
git("add", test_filename, _cwd=self.tmp_git_repo)
# https://amoffat.github.io/sh/#interactive-callbacks
git("commit", "-m", message, _cwd=self.tmp_git_repo, _tty_in=True, _out=out)
return test_filename
示例14: init_repo
def init_repo(self, dir):
if os.access(dir + ".git", os.F_OK):
return
else:
sh.git("init")
self.__ignores()
sh.touch("SampleNote.md")
sh.git("add", "*.md")
sh.git("commit", "-a", m="Initial create.")
示例15: create_role
def create_role(roles):
for role in roles:
mkdir("-p", "roles/" + role)
mkdir("-p", "roles/" + role + "/files")
mkdir("-p", "roles/" + role + "/defaults")
mkdir("-p", "roles/" + role + "/templates")
mkdir("-p", "roles/" + role + "/tasks")
touch("roles/" + role + "/tasks/main.yml")
mkdir("-p", "roles/" + role + "/handlers")