-
Notifications
You must be signed in to change notification settings - Fork 0
/
update
executable file
·40 lines (37 loc) · 1.56 KB
/
update
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
#!/usr/bin/env python
# For copyright and license terms, see COPYRIGHT.rst (top level of repository)
# Repository: https://github.com/C3S/c3s.ado
'''Builds and updates dev and production environment'''
from __future__ import print_function
import os
import shutil
import subprocess
import config
base_path = os.path.dirname(os.path.abspath(__file__))
for repos, branch, path in config.repositories:
target_path = os.path.join(base_path, path)
if not os.path.exists(target_path):
print('mkdir {}'.format(target_path))
os.makedirs(target_path)
if repos:
try:
clone_result = subprocess.check_output(
('git', 'clone', branch, repos, target_path),
stderr=subprocess.STDOUT)
print(
'git clone "{}": '.format(os.path.basename(target_path)))
except subprocess.CalledProcessError as e:
pull_result = subprocess.check_output(
('git', 'pull', '--no-stat'), cwd=target_path,
stderr=subprocess.STDOUT)
print(
'git pull "{}": '.format(os.path.basename(target_path)),
end='')
if pull_result:
print('::'.join(x for x in pull_result.strip().split('\n')))
for source_filename, target_filename in config.configfiles:
target = os.path.join(base_path, target_filename)
if not os.path.isfile(target):
source = os.path.join(base_path, source_filename)
print('copy file %s to %s' % (source_filename, target_filename))
shutil.copyfile(source, target)