forked from boskee/Minecraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager.py
76 lines (53 loc) · 1.4 KB
/
manager.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
75
76
# -*- coding: UTF-8 -*-
"""Manager module just to organize some tasks. It helps to compile and run the
game. Also cleans the directory, deleting .pyc and temporary files.
There is functionalities to commit and push/pull.
"""
# Imports, sorted alphabetically.
# Python packages
import subprocess
import sys
# Third-party packages
# Nothing for now...
# Modules from this project
# Nothing for now...
src = 'src'
images = 'resources/images'
sounds = 'resources/sounds'
def bash(command):
"""Run the command on bash"""
print(command)
subprocess.call(command, shell=True)
def clean():
"""Clean the repository."""
command = 'rm %s/*.pyc' % src
bash(command)
bash('clear')
def run():
"""Compile all files .py and run main.py."""
command = 'python %s/main.py' % src
bash(command)
def commit(msg):
"""
Commit on git.
"""
clean()
bash('git add README.md TODO.md LICENSE manager.py')
bash('git add %s/*.py %s/*' % (src, images)) #TODO put 'sounds' dir
bash('git commit -m "%s"' % msg)
def update(mode):
""""""
bash('git %s origin master' % mode)
args = sys.argv[1:]
if '--clean' in args:
clean()
if '--run' in args:
run()
if '--commit' in args:
index = sys.argv.index('--commit')
msg = sys.argv[index + 1]
commit(msg)
if '--update' in args:
index = sys.argv.index('--update')
mode = sys.argv[index + 1]
update(mode)