Compare commits
No commits in common. "ca37003f32dce3b351b5671e7684f8564ab5b020" and "4ba6832845ab2755e20d82ba8bec37a610e0c882" have entirely different histories.
ca37003f32
...
4ba6832845
|
@ -9,13 +9,11 @@ import java.net.URL;
|
|||
import java.io.BufferedInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
boolean help_enqueued = false;
|
||||
boolean allow_networking = true;
|
||||
String matrix_file_name = "";
|
||||
int verbosity = 1;
|
||||
|
||||
int p = 0;
|
||||
|
@ -34,7 +32,8 @@ public class Main {
|
|||
p += 2;
|
||||
}
|
||||
else {
|
||||
matrix_file_name = args[p++];
|
||||
System.err.println("[ERROR] Unknown argument found: " + args[p] + "\n[ERROR] Please, use 'java Main -h' for help");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -48,20 +47,6 @@ public class Main {
|
|||
printHelp(allow_networking);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
if (Objects.equals("", matrix_file_name)) {
|
||||
System.err.println("[WARN] No filename specified to read from, using default one");
|
||||
matrix_file_name = "random_matrix.txt";
|
||||
}
|
||||
|
||||
File matrix_file = new File(matrix_file_name);
|
||||
if (!matrix_file.exists()) {
|
||||
if (allow_networking) {
|
||||
System.err.println("[WARN] File is missing, downloading random matrix from the server");
|
||||
fetchResource("http://lab2.kpi.dev:16554/matrix.py", matrix_file_name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void fetchResource(String remote_url, String output_filename) {
|
||||
|
@ -87,7 +72,7 @@ public class Main {
|
|||
System.err.println("[WARN] Help file is missing.");
|
||||
if (allow_net) {
|
||||
System.err.println("[INFO] Trying to recover it from the git server");
|
||||
fetchResource("http://lab2.kpi.dev:3000/dymik739/oop-labs-collection/raw/branch/lab2-dev/labs/2/src/help.txt", "src/help.txt");
|
||||
fetchResource("http://139.162.162.130:3000/dymik739/oop-labs-collection/raw/branch/lab2-dev/labs/2/src/help.txt", "src/help.txt");
|
||||
} else {
|
||||
System.err.println("[INFO] Networking is disabled, not recovering");
|
||||
System.exit(1);
|
||||
|
@ -95,12 +80,14 @@ public class Main {
|
|||
}
|
||||
|
||||
Scanner help_file_scanner = new Scanner(help_file);
|
||||
String help_text = "";
|
||||
|
||||
while (help_file_scanner.hasNextLine()) {
|
||||
System.out.print(help_file_scanner.nextLine());
|
||||
help_text += help_file_scanner.nextLine();
|
||||
}
|
||||
|
||||
help_file_scanner.close();
|
||||
System.out.println(help_text);
|
||||
} catch (Exception e) {
|
||||
System.out.println("[ERROR] Failed to read help due to the following exception: " + e);
|
||||
System.exit(1);
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
import random
|
||||
print("Content-Type: text/plain\n\n" + "\n".join([" ".join(list(map(str, [random.randint(-40, 40) for i in range(7)]))) for i in range(7)]))
|
Loading…
Reference in New Issue