Skip to content

Commit 1de494d

Browse files
author
btskinner
committed
new menu depending on whether online or not
1 parent 590aa2f commit 1de494d

4 files changed

Lines changed: 47 additions & 27 deletions

File tree

grm/__info__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.1.6'
1+
__version__ = '0.2.0'
22
__gh = 'https://github.com/btskinner/'
33
__nm = 'grm'
44
__rp = '{}{}'.format(__gh, __nm)

grm/__init__.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,34 @@ def main():
1414

1515
def __menu():
1616

17+
# update GitRoom Objects if cycling through program
18+
connect_code = gr.getGitRoomObjs()
19+
20+
# main prompt
1721
prompt = 'What would you like to do?'
18-
opts = ['Initialize class',
19-
'Add students to class',
20-
'Add new administrator',
21-
'Clone repositories',
22-
'Update student remote repositories with local master',
23-
'Pull down from remote student repositories',
24-
'Push from local student repositories to remotes',
25-
'Grade student assignments',
26-
'<< Exit Program >>']
22+
23+
fullopts = ['Initialize class',
24+
'Add students to class',
25+
'Add new administrator',
26+
'Clone repositories',
27+
'Update student remote repositories with local master',
28+
'Pull down from remote student repositories',
29+
'Push from local student repositories to remotes',
30+
'Grade student assignments',
31+
'<< Exit Program >>']
32+
33+
shortopts = [fullopts[i] for i in [len(fullopts) - 2, len(fullopts) - 1]]
34+
35+
opts = shortopts if connect_code != 0 else fullopts
36+
2737
choice = pickOpt(prompt, opts)
2838

2939
# exit program
3040
if choice == len(opts) - 1:
3141
return
3242

33-
# update GitRoom Objects if cycling through program
34-
gr.getGitRoomObjs()
43+
if connect_code != 0:
44+
choice += len(fullopts) - len(shortopts)
3545

3646
# (1) Initialize class
3747
if choice == 0:
@@ -72,10 +82,11 @@ def __menu():
7282
else:
7383
grader = Grader(gr.lgo)
7484
grader.main()
75-
prompt = 'Do you want to push comments to student remotes?'
76-
choice = pickOpt(prompt, ['Yes','No'])
77-
if choice == 0:
78-
gr.pushGR()
85+
if connect_code == 0:
86+
prompt = 'Do you want to push comments to student remotes?'
87+
choice = pickOpt(prompt, ['Yes','No'])
88+
if choice == 0:
89+
gr.pushGR()
7990

8091
prompt = 'Do you have other tasks or wish to exit GitRoom Manager?'
8192
choice = pickOpt(prompt, ['I have another task', 'Exit'])

grm/gr.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,17 @@ def _initGitRoom(self, github_login = None, token_file = None,
8888
else:
8989
progExit()
9090

91+
try:
92+
self.rgo.getMembers()
93+
94+
except requests.exceptions.ConnectionError:
95+
errorMessage('Not able to connect to remote.')
96+
return 1
97+
9198
self.rgo.getMembers()
9299
self.rgo.getTeams()
93100
self.rgo.getRepos()
101+
return 0
94102

95103
def _readGitRoomInfo(self, init_file_path):
96104

@@ -107,12 +115,13 @@ def _readGitRoomInfo(self, init_file_path):
107115
except KeyError:
108116
info[k] = None
109117

110-
self._initGitRoom(github_login = info['github_login'],
111-
token_file = info['github_token_file'],
112-
orgname = info['organization_name'],
113-
roster_file = info['roster_file'],
114-
master_repo = info['master_repo'],
115-
student_repo_dir = info['student_repo_dir'])
118+
connect_code = self._initGitRoom(github_login = info['github_login'],
119+
token_file = info['github_token_file'],
120+
orgname = info['organization_name'],
121+
roster_file = info['roster_file'],
122+
master_repo = info['master_repo'],
123+
student_repo_dir = info['student_repo_dir'])
124+
return connect_code
116125

117126
def getGitRoomObjs(self):
118127
if self.rgo and self.lgo:
@@ -128,8 +137,8 @@ def getGitRoomObjs(self):
128137
prompt = 'Please give path to GitRoom JSON file: '
129138
grjson = os.path.expanduser(input(prompt).strip())
130139
if os.path.isfile(grjson):
131-
self._readGitRoomInfo(grjson)
132-
break
140+
connect_code = self._readGitRoomInfo(grjson)
141+
return connect_code
133142
else:
134143
errorMessage('Not a file!')
135144
continue

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ def readme():
1414

1515
setup(name=info['__nm'],
1616
version=info['__version__'],
17-
description='GitHub classroom manager',
17+
description='GitRoom Manager: A command line GitHub classroom manager',
1818
long_description=readme(),
1919
classifiers=[
20-
'Development Status :: 3 - Alpha',
20+
'Development Status :: 4 - Beta',
2121
'License :: OSI Approved :: MIT License',
22-
'Programming Language :: Python :: 3.5',
22+
'Programming Language :: Python :: 3',
2323
],
2424
keywords='github organization classroom manager',
2525
url=info['__rp'],

0 commit comments

Comments
 (0)