• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sh.touch函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sh.touch函数的典型用法代码示例。如果您正苦于以下问题:Python touch函数的具体用法?Python touch怎么用?Python touch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了touch函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:InGenious-Justice,项目名称:packman,代码行数:7,代码来源:test_packman.py


示例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()
开发者ID:dusktreader,项目名称:dot,代码行数:7,代码来源:configure.py


示例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
开发者ID:Gwill,项目名称:python-dotenv,代码行数:27,代码来源:test_cli.py


示例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.')
开发者ID:cerivera,项目名称:syncer,代码行数:34,代码来源:main.py


示例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)
开发者ID:Hawatel,项目名称:gitlint,代码行数:7,代码来源:integration_test.py


示例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)
开发者ID:aniketmaithani,项目名称:python-dotenv,代码行数:8,代码来源:test_cli.py


示例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'
开发者ID:theskumar,项目名称:python-dotenv,代码行数:8,代码来源:test_cli.py


示例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))
开发者ID:Sanji-IO,项目名称:sanji-bundle-reboot,代码行数:8,代码来源:test_reboot.py


示例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))
开发者ID:Sanji-IO,项目名称:sanji-bundle-reboot,代码行数:8,代码来源:test_reboot.py


示例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')
开发者ID:ayenzky,项目名称:urubu,代码行数:8,代码来源:test_doc.py


示例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)
开发者ID:zztimy,项目名称:unnaturalcode,代码行数:8,代码来源:test_http.py


示例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")
开发者ID:mtpereira,项目名称:scripts,代码行数:8,代码来源:ansible-dirs.py


示例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
开发者ID:jgrund,项目名称:gitlint,代码行数:9,代码来源:base.py


示例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.")
开发者ID:RemyPorter,项目名称:Notes,代码行数:9,代码来源:versioner.py


示例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")
开发者ID:mtpereira,项目名称:scripts,代码行数:9,代码来源:ansible-dirs.py


示例16: test_empty_file

def test_empty_file():
    filename = 'empty'
    loop = BooleanLoop()
    launcher.on_transfer_ended(
        loop.stop, d_from='rep1', d_to='rep2', filename=filename
    )
    sh.touch(os.path.join(rep1, filename))
    loop.run(timeout=5)
    assert os.path.getsize(os.path.join(rep2, filename)) == 0
开发者ID:onitu,项目名称:onitu,代码行数:9,代码来源:test_copy.py


示例17: test_get_key

def test_get_key():
    sh.touch(dotenv_path)
    success, key_to_set, value_to_set = dotenv.set_key(dotenv_path, 'HELLO', 'WORLD')
    stored_value = dotenv.get_key(dotenv_path, 'HELLO')
    assert stored_value == 'WORLD'
    sh.rm(dotenv_path)
    assert dotenv.get_key(dotenv_path, 'HELLO') is None
    success, key_to_set, value_to_set = dotenv.set_key(dotenv_path, 'HELLO', 'WORLD')
    assert success is None
开发者ID:aniketmaithani,项目名称:python-dotenv,代码行数:9,代码来源:test_cli.py


示例18: test_load_dotenv

def test_load_dotenv(tmp_path):
    os.chdir(str(tmp_path))
    dotenv_path = '.test_load_dotenv'
    sh.touch(dotenv_path)
    set_key(dotenv_path, 'DOTENV', 'WORKS')
    assert 'DOTENV' not in os.environ
    success = load_dotenv(dotenv_path)
    assert success
    assert 'DOTENV' in os.environ
    assert os.environ['DOTENV'] == 'WORKS'
开发者ID:theskumar,项目名称:python-dotenv,代码行数:10,代码来源:test_core.py


示例19: setUp

 def setUp(self):
     self.dir = tempfile.mkdtemp()
     sh.cd(self.dir)
     sh.git.init()
     sh.git('config', 'user.name', '"Daniël"')
     sh.git('config', 'user.email', '"[email protected]"')
     sh.touch('README')
     sh.git.add('README')
     sh.git.commit('-m', 'first commit')
     sh.git('remote', 'add', 'origin', 'https://github.com/username/Hello-World.git')
开发者ID:Jwpe,项目名称:coveralls-python,代码行数:10,代码来源:test_api.py


示例20: test_should_rebase_by_default

    def test_should_rebase_by_default(self):
        from sh import touch

        touch('foo')
        git('add', 'foo')
        fix('HEAD')

        actual = git_show('HEAD')['subject']
        expected = 'commit1'
        self.assertEqual(expected, actual)
开发者ID:themalkolm,项目名称:git-boots,代码行数:10,代码来源:test_fix.py



注:本文中的sh.touch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sh.unzip函数代码示例发布时间:2022-05-27
下一篇:
Python sh.tar函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap