mirror of
https://github.com/Balshgit/github_mirror.git
synced 2025-09-11 22:40:44 +03:00
replace kwargs for more clearly
This commit is contained in:
parent
2410429e03
commit
f392b4c879
@ -37,10 +37,10 @@ def create_parser() -> ArgumentParser:
|
|||||||
parser.add_argument('-g', '--group', required=False, type=int,
|
parser.add_argument('-g', '--group', required=False, type=int,
|
||||||
help='Add group id it can be found under group name. Id must be integer')
|
help='Add group id it can be found under group name. Id must be integer')
|
||||||
|
|
||||||
parser.add_argument('-u', '--urls', nargs='+', help='Provide url or urls to mirror with it in format: '
|
parser.add_argument('-u', '--urls', nargs='+',
|
||||||
'https://github.com/s3rius/FastAPI-template.git. '
|
help='Provide url or urls to mirror with it in format: '
|
||||||
'You can provide multiple urls separated by space. '
|
'https://github.com/s3rius/FastAPI-template.git. You can provide multiple urls '
|
||||||
'Names will generate automatically from links')
|
'separated by space. Names will generate automatically from links')
|
||||||
|
|
||||||
parser.add_argument('-f', '--file', help='Add file with urls. Each url on new line. Can be combined with '
|
parser.add_argument('-f', '--file', help='Add file with urls. Each url on new line. Can be combined with '
|
||||||
'--url option. Names will generate automatically from links')
|
'--url option. Names will generate automatically from links')
|
||||||
|
@ -92,13 +92,14 @@ class RepositoryCreator:
|
|||||||
elif request.status_code != self.HTTP_200_OK:
|
elif request.status_code != self.HTTP_200_OK:
|
||||||
logger.error(f'Error pull repository. Status code: {request.status_code}. Reason: {request.text}')
|
logger.error(f'Error pull repository. Status code: {request.status_code}. Reason: {request.text}')
|
||||||
|
|
||||||
def create_repository_mirror(self, **kwargs):
|
def create_repository_mirror(self, github_url: str, group_id: int):
|
||||||
"""
|
"""
|
||||||
Base action for one thread. Creates repository, add mirror url and triggers pull at te end
|
Base action for one thread. Creates repository, add mirror url and triggers pull at te end
|
||||||
|
|
||||||
:param kwargs: Can contain github url to mirror of, gitlab group ID
|
:param github_url: Github url which will be mirrored
|
||||||
|
:param group_id: Gitlab group id which contains created repository
|
||||||
"""
|
"""
|
||||||
repo_id = self.__create_new_project(kwargs['url'], kwargs['group_id'])
|
repo_id = self.__create_new_project(github_url, group_id)
|
||||||
url = self.__add_pull_mirror(kwargs['url'], repo_id)
|
url = self.__add_pull_mirror(github_url, repo_id)
|
||||||
if url:
|
if url:
|
||||||
self.__pull_github_repo(url, repo_id)
|
self.__pull_github_repo(url, repo_id)
|
||||||
|
@ -73,4 +73,18 @@ https://github.com/django/django.git
|
|||||||
https://github.com/KristianOellegaard/django-health-check.git
|
https://github.com/KristianOellegaard/django-health-check.git
|
||||||
https://github.com/wemake-services/django-split-settings.git
|
https://github.com/wemake-services/django-split-settings.git
|
||||||
https://github.com/jazzband/django-constance.git
|
https://github.com/jazzband/django-constance.git
|
||||||
https://github.com/numpy/numpy.git
|
https://github.com/numpy/numpy.git
|
||||||
|
https://github.com/mher/flower.git
|
||||||
|
https://github.com/hynek/structlog.git
|
||||||
|
https://github.com/bradmontgomery/django-querycount.git
|
||||||
|
https://github.com/justinmayer/django-autoslug.git
|
||||||
|
https://github.com/SmileyChris/easy-thumbnails.git
|
||||||
|
https://github.com/jonasundderwolf/django-image-cropping.git
|
||||||
|
https://github.com/marshmallow-code/marshmallow.git
|
||||||
|
https://github.com/TvoroG/pytest-lazy-fixture.git
|
||||||
|
https://github.com/PyCQA/flake8.git
|
||||||
|
https://github.com/getsentry/responses.git
|
||||||
|
https://github.com/gotcha/ipdb.git
|
||||||
|
https://github.com/pypa/setuptools.git
|
||||||
|
https://github.com/jazzband/django-redis.git
|
||||||
|
https://github.com/sebleier/django-redis-cache.git
|
@ -1,5 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
from threading import Thread, Semaphore
|
from threading import Thread
|
||||||
|
|
||||||
from core.argument_parser import create_parser
|
from core.argument_parser import create_parser
|
||||||
from core.repo_creator import RepositoryCreator
|
from core.repo_creator import RepositoryCreator
|
||||||
@ -33,15 +33,13 @@ def main():
|
|||||||
if mirror_urls:
|
if mirror_urls:
|
||||||
for url in set(mirror_urls): # github urls must be unique
|
for url in set(mirror_urls): # github urls must be unique
|
||||||
thread = Thread(target=repository_creator.create_repository_mirror,
|
thread = Thread(target=repository_creator.create_repository_mirror,
|
||||||
kwargs={'url': url, 'group_id': group_id, })
|
kwargs={'github_url': url, 'group_id': group_id, })
|
||||||
threads.append(thread)
|
threads.append(thread)
|
||||||
|
|
||||||
for thread in threads:
|
for thread in threads:
|
||||||
with Semaphore(50):
|
thread.start()
|
||||||
thread.start()
|
|
||||||
|
|
||||||
threads_ready_statistic(threads) # add threads ready status to log output
|
threads_ready_statistic(threads) # add threads ready status to log output
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.info('You must provide at least one github url for mirror')
|
logger.info('You must provide at least one github url for mirror')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user