def update_updater(self, *args):
#if self.printer_model == 'Robo R2':
# branch = 'r2'
#else:
# branch = 'c2'
branch = 'master'
if os.path.exists(self.repo_local_path):
def del_rw(action, name, exc):
os.chmod(name, stat.S_IWRITE)
os.remove(name)
# start fresh every time to avoid potential corruptions or misconfigurations
rmtree(self.repo_local_path, onerror=del_rw)
Repo.clone_from(self.repo_remote_path, self.repo_local_path, branch=branch)
python类clone_from()的实例源码
def update_local_repo():
if not os.path.isdir(LOCAL_REPO_DIR):
os.makedirs(LOCAL_REPO_DIR)
if not os.path.isdir(RECIPE_REPO_DIR):
Repo.clone_from(GITHUB_URL, RECIPE_REPO_DIR)
Repo(RECIPE_REPO_DIR).remotes.origin.pull()
def clone_github_repo(self):
"""
Clones a github repo with a username and repository_name
"""
if not (self.username and self.repository_name):
return
repository_local_destination = join(MODULES_PATH, 'github', self.username, self.repository_name)
if not exists(repository_local_destination):
Repo.clone_from(self.repo_url, repository_local_destination, branch='master')
init_filename = join(repository_local_destination, '__init__.py')
open(init_filename, 'a').close()
def clone_github_repo(self):
"""
Clones a github repo with a username and repository_name
"""
repository_local_destination = os.path.join(MODULES_PATH, 'github', self.username, self.repository_name)
if not os.path.exists(repository_local_destination):
Repo.clone_from(self.repo_url, repository_local_destination, branch='master')
init_filename = os.path.join(repository_local_destination, '__init__.py')
open(init_filename, 'a').close()
def update_updater(self, *args):
if self.printer_model == 'Robo R2':
branch = 'r2'
else:
branch = 'c2'
if os.path.exists(self.repo_local_path):
# start fresh every time to avoid potential corruptions or misconfigurations
rmtree(self.repo_local_path)
Repo.clone_from(self.repo_remote_path, self.repo_local_path, branch=branch)
def clone(repo, path):
"""Clone a given repository object to the specified path.
"""
try:
shutil.rmtree(path)
except FileNotFoundError:
pass
finally:
logging.debug("cloning {}".format(repo.clone_url))
repo_local = Repo.clone_from(repo.clone_url, path)
def main():
peepdf_path = os.path.join(VENDOR_ROOT, "peepdf")
if not os.path.isfile(os.path.join(peepdf_path, "peepdf.py")):
Repo.clone_from('https://github.com/jesparza/peepdf', peepdf_path)
def main():
try:
import volatility
except ImportError:
volpath = os.path.join(VENDOR_ROOT, "volatility")
setup_script = os.path.join(volpath, "setup.py")
rmtree(volpath, True)
Repo.clone_from("https://github.com/volatilityfoundation/volatility.git", volpath)
os.chdir(volpath)
call(['python', setup_script, 'install'])
def main():
decoders_path = os.path.join(VENDOR_ROOT, 'RATDecoders')
if os.path.exists(decoders_path):
repo = Repo(decoders_path)
repo.remotes.origin.pull()
else:
Repo.clone_from("https://github.com/kevthehermit/RATDecoders.git", decoders_path)
def install(self):
try:
Repo.clone_from(self.url, self.app.config['SKILL_FOLDER'] + self.name)
json.path = self.app.config['SKILL_FOLDER'] + self.name + "/package.json"
data = json.decode_path()
self.install_dep(data)
self.install_pip(data)
skill = get_skill_function(self.app.config['SKILL_FOLDER'], self.name)
if (hasattr(skill, 'create_skill') and callable(skill.create_skill)):
Module = skill.create_skill()
if (hasattr(Module, 'install') and callable(Module.install)):
try:
Module.install()
except Exception as e:
logger.error('Install Skill error for ' + self.name + ' : ' + str(e))
if (hasattr(Module, 'get_blueprint') and callable(Module.get_blueprint)):
self.app.register_blueprint(Module.get_blueprint())
if data['navbar'] == 'True':
navbar.folder = self.name
navbar.set_plugin_navbar()
os.system('cd ' + self.app.config['SKILL_FOLDER'] + self.name + ' && make compilelang')
bot = kernel.set()
kernel.train(bot)
logger.info('Installation done with success')
return json.encode({"status":"success"})
except Exception as e:
logger.error('Installation error : ' + str(e))
return json.encode({"status":"error"})
def get_data(self):
try:
Repo.clone_from('https://github.com/OnyxProject/onyx-data', onyx.__path__[0] + "/data/")
logger.info('Successfully get Data')
except Exception as e:
logger.error('Get Data error : ' + str(e))
raise DataException(str(e))
def clone(self, outdir):
LOG.debug("Cloning '%s' to '%s'", self.url, outdir)
kwargs = {'recursive': True}
if self._depth:
LOG.debug("Cloning with depth=%d", self._depth)
kwargs['depth'] = self._depth
self._repo = Repo.clone_from(self.url, outdir, **kwargs)
git = self._repo.git
git.checkout(self.branch)
self._invalidate_attrs()
def update(ctx):
await say(ctx.message, "Updating...")
import platform
try:
from git import Repo
except ImportError:
await say(ctx.message, "Please install the module gitpython.".format(pip_os))
return
import shutil
from distutils.dir_util import copy_tree
import stat
try:
os.remove("oldconfig.json")
except OSError:
pass
os.rename("config.json", "oldconfig.json")
os.remove("embedbot.py") #lol r i p embedbot if this doesn't work r i p my work
os.remove("README.md")
os.remove("requirements.txt")
repo_url = "https://www.github.com/Luigimaster1/embedbot.git"
local_dir = "./tempupdate/"
Repo.clone_from(repo_url, local_dir)
def del_rw(action, name, exc):
os.chmod(name, stat.S_IWRITE)
os.remove(name)
shutil.rmtree("./tempupdate/.git/", onerror=del_rw)
copy_tree(local_dir, ".")
shutil.rmtree("./tempupdate/", onerror=del_rw)
os.remove("botinfo.json")
await say(ctx.message, "The bot has been updated. Please restart the bot.")
def repo_clone(repo_dir, repo_url):
"""Clone repository to this host."""
repo = Repo.clone_from(repo_url, repo_dir)
return repo
def clone_git_repo(git_url):
project_path = tempfile.mkdtemp()
Repo.clone_from(git_url, project_path)
return project_path
def clone_repository(repository):
repo_url = repository.url
repo_path = repository.get_local_repo_path()
Frontend.set_auth(repository)
try:
repo = Repo.clone_from(repository.url, repository.get_local_repo_path(), branch='master')
repository.conn_ok = True
except:
repository.conn_ok = False
repository.save()
def fetch(url, rev, path):
repo = Repo.clone_from(url, path)
if repo.bare:
raise RuntimeError('Empty repo ' + url)
git = repo.git
git.checkout(rev)
repo.create_head(rev)
return repo.head.object.hexsha
def get_repo(self):
path = self.get_path()
if os.path.exists(path):
self.logger.info('found_repo')
return Repo(path)
self.logger.info('cloning_repo')
return Repo.clone_from(self.uri, path)