本文整理汇总了Python中git.Repo.create方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.create方法的具体用法?Python Repo.create怎么用?Python Repo.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Repo
的用法示例。
在下文中一共展示了Repo.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create [as 别名]
def init(self, path):
try:
Repo.create(path)
message = "Success"
except IOError:
message = "Problem writing folder"
return message
示例2: __init__
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create [as 别名]
def __init__(self, manager):
super(PuppetInstallMethod, self).__init__(manager)
self.log = logging.getLogger(__name__)
# Use effective agent user's home directory
self.__path = pwd.getpwuid(os.getuid()).pw_dir
# Load install items
for entry in pkg_resources.iter_entry_points("puppet.items"):
module = entry.load()
self.log.info("repository handler %s included" % module.__name__)
self._supportedItems.update({
module.__name__ : {
'name': module._name,
'description': module._description,
'container': module._container,
'options': module._options,
'module': module,
},
})
# Get a backend instance for that path
self.__repo_path = os.path.join(self.__path, "repo")
self.__work_path = os.path.join(self.__path, "work")
# Purge path if wanted
db_purge = self.env.config.get('repository.db_purge',)
if db_purge == "True":
if os.path.exists(self.__repo_path):
shutil.rmtree(self.__repo_path)
if os.path.exists(self.__work_path):
shutil.rmtree(self.__work_path)
# Create path if it doesn't exist
if not os.path.exists(self.__path):
os.makedirs(self.__path, 0750)
if not os.path.exists(self.__repo_path):
os.makedirs(self.__repo_path, 0750)
if not os.path.exists(self.__work_path):
os.makedirs(self.__work_path, 0750)
# Initialize git repository if not present
if not os.path.exists(os.path.join(self.__repo_path, "config")):
repo = Repo.create(self.__repo_path)
assert repo.bare == True
os.chmod(self.__repo_path, 0750)
# Create master branch
tmp_path = os.path.join(self.__work_path, "master")
cmd = Git(self.__work_path)
cmd.clone(self.__repo_path, "master")
with open(os.path.join(tmp_path, "README"), "w") as f:
f.write("This is an automatically managed GOsa puppet repository. Please do not modify.")
logdir = self.env.config.get("puppet.report-dir",
"/var/log/puppet")
with open(os.path.join(tmp_path, "puppet.conf"), "w") as f:
f.write("""[main]
logdir=%s
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
templatedir=$confdir/templates
report=true
reports=store_gosa
reportdir=$logdir
""" % logdir)
# Add manifests and write initial size.pp
os.mkdir(os.path.join(tmp_path, "manifests"))
with open(os.path.join(tmp_path, "manifests", "site.pp"), "w") as f:
f.write('\nimport "nodes.pp"\n')
# Add manifests and write initial size.pp
with open(os.path.join(tmp_path, "manifests", "nodes.pp"), "w") as f:
f.write('# Automatically managed by GOsa\n')
cmd = Git(tmp_path)
cmd.add("README")
cmd.add("puppet.conf")
cmd.add("manifests")
cmd.commit(m="Initially created puppet master branch")
cmd.push("origin", "master")
shutil.rmtree(tmp_path)
# Create SSH directory?
self.ssh_path = os.path.join(self.__path, '.ssh')
if not os.path.exists(self.ssh_path):
os.makedirs(self.ssh_path)
host = self.env.id
user = pwd.getpwuid(os.getuid()).pw_name
self.gen_ssh_key(os.path.join(self.ssh_path, 'id_dsa'),
"%[email protected]%s" % (user, host))