Skip to content

Commit 1994d47

Browse files
committed
switching to the new login for all applications
1 parent 102f78e commit 1994d47

File tree

5 files changed

+51
-31
lines changed

5 files changed

+51
-31
lines changed

LabCodeRepoSetup/src/main/java/edu/wpi/rbe/DownloadAllHomeworkRepos.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public class DownloadAllHomeworkRepos {
3434
* @param args
3535
*/
3636
public static void main(String[] args) throws Exception {
37-
String teamAssignmentsFile = args[0];
37+
String teamAssignmentsFile = LabCodeRepoSetupMain.getTeamAssignmentFile(args);
38+
GitHub github = LabCodeRepoSetupMain.getGithub();
3839
int numberOfTeams = 0;
3940

4041
Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
@@ -46,7 +47,6 @@ public static void main(String[] args) throws Exception {
4647
ArrayList<String> repoDestBaseNames = teamAssignments.get("repoDestBaseNames");
4748
numberOfTeams = Integer.parseInt(teamAssignments.get("numberOfTeams").get(0));
4849

49-
GitHub github = GitHub.connect();
5050
GHOrganization dest = github.getMyOrganizations().get(projectDestBaseName);
5151

5252
if (dest == null) {
@@ -93,7 +93,7 @@ public static void main(String[] args) throws Exception {
9393
}
9494
}
9595
}
96-
96+
System.exit(0);
9797
}
9898

9999
}

LabCodeRepoSetup/src/main/java/edu/wpi/rbe/DownloadAllLabRepos.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public class DownloadAllLabRepos {
3434
* @param args
3535
*/
3636
public static void main(String[] args) throws Exception {
37-
String teamAssignmentsFile = args[0];
37+
String teamAssignmentsFile = LabCodeRepoSetupMain.getTeamAssignmentFile(args);
38+
GitHub github = LabCodeRepoSetupMain.getGithub();
3839
int numberOfTeams = 0;
3940

4041
Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
@@ -46,7 +47,6 @@ public static void main(String[] args) throws Exception {
4647
ArrayList<String> repoDestBaseNames = teamAssignments.get("repoDestBaseNames");
4748
numberOfTeams = Integer.parseInt(teamAssignments.get("numberOfTeams").get(0));
4849

49-
GitHub github = GitHub.connect();
5050
GHOrganization dest = github.getMyOrganizations().get(projectDestBaseName);
5151

5252
if (dest == null) {
@@ -94,7 +94,7 @@ public static void main(String[] args) throws Exception {
9494
}
9595
}
9696
}
97-
97+
System.exit(0);
9898
}
9999

100100
}

LabCodeRepoSetup/src/main/java/edu/wpi/rbe/LabCodeRepoSetupMain.java

+36-20
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ public class LabCodeRepoSetupMain {
4646
*/
4747
public static void main(String[] args) throws Exception {
4848
HashSet<GHUser> allStudents = new HashSet<>();
49-
String path = FileSelectionFactory.GetFile(
50-
new File(".")
51-
,new ExtensionFilter("json file","*.JSON","*.json")
52-
)
53-
.getAbsolutePath();
54-
String teamAssignmentsFile = path;
49+
50+
51+
String teamAssignmentsFile = LabCodeRepoSetupMain.getTeamAssignmentFile(args);
52+
GitHub github = LabCodeRepoSetupMain.getGithub();
53+
5554
int numberOfTeams = 0;
5655

5756
Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
@@ -115,20 +114,6 @@ public static void main(String[] args) throws Exception {
115114
}
116115

117116

118-
File workspace = new File(System.getProperty("user.home") + "/bowler-workspace/");
119-
if (!workspace.exists()) {
120-
workspace.mkdir();
121-
}
122-
try {
123-
PasswordManager.loadLoginData(workspace);
124-
} catch (Exception e) {
125-
// TODO Auto-generated catch block
126-
e.printStackTrace();
127-
}
128-
PasswordManager.login();
129-
GitHub github = PasswordManager.getGithub();
130-
131-
132117
GHOrganization dest = github.getMyOrganizations().get(projectDestBaseName);
133118

134119
if (dest == null) {
@@ -422,7 +407,38 @@ public static void main(String[] args) throws Exception {
422407
}
423408
}
424409
}
410+
System.exit(0);
411+
}
425412

413+
public static String getTeamAssignmentFile(String[] args) {
414+
@SuppressWarnings("restriction")
415+
String path = FileSelectionFactory.GetFile(
416+
new File(".")
417+
,new ExtensionFilter("json file","*.JSON","*.json")
418+
)
419+
.getAbsolutePath();
420+
String teamAssignmentsFile;
421+
if(args.length==0)
422+
teamAssignmentsFile= path;
423+
else
424+
teamAssignmentsFile=args[0];
425+
return teamAssignmentsFile;
426+
}
427+
428+
public static GitHub getGithub() throws IOException {
429+
File workspace = new File(System.getProperty("user.home") + "/bowler-workspace/");
430+
if (!workspace.exists()) {
431+
workspace.mkdir();
432+
}
433+
try {
434+
PasswordManager.loadLoginData(workspace);
435+
} catch (Exception e) {
436+
// TODO Auto-generated catch block
437+
e.printStackTrace();
438+
}
439+
PasswordManager.login();
440+
GitHub github = PasswordManager.getGithub();
441+
return github;
426442
}
427443

428444
public static void run(List<String> commands, File dir) throws Exception {

LabCodeRepoSetup/src/main/java/edu/wpi/rbe/TeamPermissionSets.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public class TeamPermissionSets {
4343
*/
4444
public static void main(String[] args) throws Exception {
4545
HashSet<GHUser> allStudents = new HashSet<>();
46-
String teamAssignmentsFile = args[0];
46+
47+
String teamAssignmentsFile = LabCodeRepoSetupMain.getTeamAssignmentFile(args);
48+
GitHub github = LabCodeRepoSetupMain.getGithub();
4749
int numberOfTeams = 0;
4850

4951
Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
@@ -106,7 +108,6 @@ public static void main(String[] args) throws Exception {
106108
}
107109
}
108110

109-
GitHub github = GitHub.connect();
110111
GHOrganization dest = github.getMyOrganizations().get(projectDestBaseName);
111112

112113
if (dest == null) {
@@ -162,7 +163,7 @@ public static void main(String[] args) throws Exception {
162163

163164
}
164165
}
165-
166+
System.exit(0);
166167
}
167168

168169
public static void run(List<String> commands, File dir) throws Exception {

LabCodeRepoSetup/src/main/java/edu/wpi/rbe/UpdateAllLabRepos.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public class UpdateAllLabRepos {
3434
* @param args
3535
*/
3636
public static void main(String[] args) throws Exception {
37-
String teamAssignmentsFile = args[0];
37+
38+
String teamAssignmentsFile = LabCodeRepoSetupMain.getTeamAssignmentFile(args);
39+
GitHub github = LabCodeRepoSetupMain.getGithub();
3840
int numberOfTeams = 0;
3941

4042
Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
@@ -46,7 +48,7 @@ public static void main(String[] args) throws Exception {
4648
ArrayList<String> repoDestBaseNames = teamAssignments.get("repoDestBaseNames");
4749
numberOfTeams = Integer.parseInt(teamAssignments.get("numberOfTeams").get(0));
4850

49-
GitHub github = GitHub.connect();
51+
5052
GHOrganization dest = github.getMyOrganizations().get(projectDestBaseName);
5153

5254
if (dest == null) {
@@ -109,6 +111,7 @@ public static void main(String[] args) throws Exception {
109111

110112
}
111113
}
114+
System.exit(0);
112115

113116
}
114117

0 commit comments

Comments
 (0)