本文整理匯總了Python中repository.Repository.init方法的典型用法代碼示例。如果您正苦於以下問題:Python Repository.init方法的具體用法?Python Repository.init怎麽用?Python Repository.init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類repository.Repository
的用法示例。
在下文中一共展示了Repository.init方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: app_setup
# 需要導入模塊: from repository import Repository [as 別名]
# 或者: from repository.Repository import init [as 別名]
def app_setup(app):
app.config['CELERY_ACCEPT_CONTENT'] = ['json']
app.config['CELERY_TASK_SERIALIZER'] = 'json'
app.config['CELERY_RESULT_SERIALIZER'] = 'json'
app.config['CELERY_BROKER_URL'] = 'redis://localhost:6379/2'
app.config['CELERY_BACKEND'] = 'redis://localhost:6379/3'
app.config['CELERY_QUEUES'] = (
Queue('transplant', Exchange('transplant'), routing_key='transplant'),
)
app.src_dir = tempfile.mkdtemp(dir=test_temp_dir)
app.dst_dir = tempfile.mkdtemp(dir=test_temp_dir)
app.config['TRANSPLANT_WORKDIR'] = tempfile.mkdtemp(dir=test_temp_dir)
app.config['TRANSPLANT_REPOSITORIES'] = [{
'name': 'test-src',
'path': app.src_dir
}, {
'name': 'test-dst',
'path': app.dst_dir
}]
app.src = Repository.init(app.src_dir)
app.dst = Repository.init(app.dst_dir)
_set_test_file_content(app.src_dir, "Hello World!\n")
app.src.commit("Initial commit", addremove=True, user="Test User")
app.dst.pull(app.src_dir, update=True)
示例2: prepare_mock_repositories
# 需要導入模塊: from repository import Repository [as 別名]
# 或者: from repository.Repository import init [as 別名]
def prepare_mock_repositories(self):
self.src_dir = tempfile.mkdtemp()
self.dst_dir = tempfile.mkdtemp()
self.workdir = tempfile.mkdtemp()
self.src = Repository.init(self.src_dir)
self.dst = Repository.init(self.dst_dir)
self._set_test_file_content(self.src_dir, "Hello World!\n")
self.src.commit("Initial commit", addremove=True)
self.dst.pull(self.src_dir, update=True)
示例3: upload_handout
# 需要導入模塊: from repository import Repository [as 別名]
# 或者: from repository.Repository import init [as 別名]
def upload_handout(class_name, local_handout_dir):
local_handout_dir = os.path.expanduser(local_handout_dir)
local_handout_dir = os.path.abspath(local_handout_dir)
handout_name = os.path.basename(local_handout_dir.rstrip('/'))
if handout_name.count(' ') != 0:
sys.exit('NO spaces allowed in handout directory')
if not os.path.isdir(local_handout_dir):
sys.exit('{0} does not exist'.format(local_handout_dir))
try:
config = GraderConfiguration(single_class_name=class_name)
except ConfigurationError as e:
sys.exit(e)
if class_name not in config.students_by_class:
sys.exit('Class {0} does not exist'.format(class_name))
remote_handout_repo_basename = handout_name + '.git'
remote_handout_repo_dir = os.path.join('/home/git', class_name,
remote_handout_repo_basename)
if directory_exists(remote_handout_repo_dir, ssh=config.ssh):
sys.exit('{0} already exists on the grader'
.format(remote_handout_repo_dir))
local_handout_repo = Repository(local_handout_dir, handout_name)
if not local_handout_repo.is_initialized():
print('Initializing local git repository in {0}'
.format(local_handout_dir))
try:
local_handout_repo.init()
local_handout_repo.add_all_and_commit('Initial commit')
except CommandError as e:
sys.exit('Error initializing local repository:\n{0}'
.format(e))
else:
print('{0} is already a git repository, it will be pushed'
.format(local_handout_dir))
print('Creating a bare repository on the grader at this path:\n{0}'
.format(remote_handout_repo_dir))
remote_handout_repo = Repository(remote_handout_repo_dir, handout_name,
is_local=False, is_bare=True,
remote_user=config.username,
remote_host=config.host,
ssh=config.ssh)
try:
remote_handout_repo.init()
except CommandError as e:
sys.exit('Error initializing remote bare repository:\n{0}'.format(e))
print('Setting the remote of the local repository')
try:
local_handout_repo.set_remote(remote_handout_repo)
except CommandError as e:
print('Error setting remote:\n{0}'.format(e))
print('Set the remote manually if need be')
print('Pushing local handout to the grader')
try:
local_handout_repo.push(remote_handout_repo)
except CommandError as e:
sys.exit('Error pushing handout:\n{0}'.format(e))
email_queue = Queue()
email_thread = Thread(target=process_email_queue, args=(email_queue,
class_name,
config))
email_thread.start()
for student in config.students_by_class[class_name]:
assert isinstance(student, Student)
clone_url = '{0}@{1}:{2}'.format(student.username, config.host,
remote_handout_repo_dir)
body = 'Clone URL:\n{0}'.format(clone_url)
subject = 'New handout: {0}'.format(handout_name)
email_queue.put(Email(student.email_address, subject, body))
email_queue.put(None)
email_thread.join()