add verbose output to checkout command
This commit is contained in:
parent
608cc8e61b
commit
74a56a9c0f
|
@ -10,7 +10,8 @@ from scrutiny.projects.models import Module
|
|||
class Command(BaseCommand):
|
||||
help = 'Create checkouts of modules'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
def handle(self, verbosity, *args, **options):
|
||||
self.verbose = int(verbosity) > 1
|
||||
checkouts_directory = os.path.join(settings.MEDIA_ROOT, 'src')
|
||||
if not os.path.exists(checkouts_directory):
|
||||
os.mkdir(checkouts_directory)
|
||||
|
@ -21,18 +22,15 @@ class Command(BaseCommand):
|
|||
|
||||
checkout_dir = os.path.join(checkouts_directory, module.name)
|
||||
|
||||
kws = {}
|
||||
kws['stdout'] = subprocess.PIPE
|
||||
kws['stderr'] = subprocess.STDOUT
|
||||
if not os.path.exists(checkout_dir):
|
||||
# full clone
|
||||
cmd = ['git', 'clone', module.repository_url, module.name]
|
||||
kws['cwd'] = checkouts_directory
|
||||
cwd = checkouts_directory
|
||||
else:
|
||||
# pull
|
||||
cmd = ['git', 'pull']
|
||||
kws['cwd'] = checkout_dir
|
||||
cwd = checkout_dir
|
||||
|
||||
p = subprocess.Popen(cmd, **kws)
|
||||
p.communicate()
|
||||
p.wait()
|
||||
if self.verbose:
|
||||
print('- ' + module.name)
|
||||
subprocess.run(cmd, capture_output=not (self.verbose), cwd=cwd)
|
||||
|
|
Loading…
Reference in New Issue