-
Notifications
You must be signed in to change notification settings - Fork 1
/
rebaseline.py
executable file
·74 lines (58 loc) · 1.85 KB
/
rebaseline.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
from subprocess import check_output
# import platform
# import os
# import tempfile
import shutil
# import time
# from colorama import Fore
from slurm.files import rm, mkdir, find
def rmdir(path):
if not isinstance(path, list):
path = [path]
for p in path:
try:
shutil.rmtree(p)
# print(p)
except FileNotFoundError:
# folder was already deleted or doesn't exist ... it's ok
pass
def run(cmd):
# given a command string, it runs it
cmds = cmd.split()
return check_output(cmds)
REMOTE = "[email protected]:walchko/github-blog.git" #"[email protected]:walchko/walchko.github.io.git"
REPO = "github.com/walchko/github-blog" #"github.com/walchko/walchko.github.io"
BRANCH = "master"
# FOLDER = "html"
# tmp = tempfile.mkdtemp()
# recursively copy everything to the tmp directory
# make a new git repo and push everything to the branch
# this will make github display the webpages
# shutil.copytree('html', tmp + '/html')
# os.chdir(tmp + '/html')
print('====================')
print(' Clean up git')
print('====================')
rm(find("./",".DS_Store"))
rm(find("./","deleteme"))
rmdir(find("./",".ipynb_checkpoints"))
rmdir(find("./","__pycache__"))
print('====================')
print(' Redoing git')
print('====================')
# create readme with data
# readme = "# Blog\n\nThis site is automatically generated\n\nUpdated on {}".format(time.strftime("%Y-%m-%d %H:%M"))
# with open('readme.md', 'w') as fd:
# fd.write(readme)
run('git init')
run('git add *')
run('git commit -m "updated-on-{}:{}-:space_invader:"'.format(REPO, BRANCH))
print('====================')
print(' git push')
print('====================')
run('git push --force {} master:{}'.format(REMOTE, BRANCH))
# from glob import glob
# print(os.getcwd())
# for g in glob('*'):
# print(g)