-
Notifications
You must be signed in to change notification settings - Fork 0
/
pullLocalReps.py
executable file
·51 lines (40 loc) · 1.27 KB
/
pullLocalReps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Rafael Corsi @ insper.edu.br
# 2021
import argparse
import yaml
import os
import subprocess
from joblib import Parallel, delayed
class pullLocalReps():
def __init__(self, reposPath, force):
self.reposPath = reposPath
if not os.path.exists(reposPath):
print('Path not found')
return
self.log = {}
def report(self):
for r, s in self.log.items():
print("{}: {}".format(r.split(sep='/')[-1], s))
def run(self):
repoFail = []
for repo in os.listdir(self.reposPath):
path = os.path.join(self.reposPath, repo)
print(path)
status = True
command = '-C {} pull origin master'.format(path)
try:
out = subprocess.check_output('git {}'.format(command), shell=True).decode('utf-8')
except:
status = False
self.log[repo] = out
if __name__ == '__main__':
argparse.ArgumentParser()
parser = argparse.ArgumentParser(prog='Update local repositories from upstream')
parser.add_argument('--path', default=None, type=str, help='repos path')
args = parser.parse_args()
plp = pullLocalReps(args.path, 1)
plp.run()
plp.report()