dscc-remote-toolkit 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dscc_remote_toolkit/__init__.py +35 -0
- dscc_remote_toolkit/cli.py +105 -0
- dscc_remote_toolkit/java/q1/CalcDatagramClient.java +37 -0
- dscc_remote_toolkit/java/q1/CalcDatagramServer.java +62 -0
- dscc_remote_toolkit/java/q10/BullyElection.java +67 -0
- dscc_remote_toolkit/java/q2/DateTimeDatagramClient.java +26 -0
- dscc_remote_toolkit/java/q2/DateTimeDatagramServer.java +33 -0
- dscc_remote_toolkit/java/q3/CalcSocketClient.java +30 -0
- dscc_remote_toolkit/java/q3/CalcSocketServer.java +61 -0
- dscc_remote_toolkit/java/q4/DateTimeSocketClient.java +17 -0
- dscc_remote_toolkit/java/q4/DateTimeSocketServer.java +25 -0
- dscc_remote_toolkit/java/q5/DateTimeRMIClient.java +19 -0
- dscc_remote_toolkit/java/q5/DateTimeRMIImpl.java +50 -0
- dscc_remote_toolkit/java/q5/DateTimeRMIInterface.java +10 -0
- dscc_remote_toolkit/java/q5/DateTimeRMIServer.java +17 -0
- dscc_remote_toolkit/java/q6/DatagramClient.java +31 -0
- dscc_remote_toolkit/java/q6/DatagramServer.java +33 -0
- dscc_remote_toolkit/java/q6/EquationImplAnirudh.java +7 -0
- dscc_remote_toolkit/java/q6/EquationInterfaceAnirudh.java +3 -0
- dscc_remote_toolkit/java/q7/LibraryClient.java +21 -0
- dscc_remote_toolkit/java/q7/LibraryImpl.java +42 -0
- dscc_remote_toolkit/java/q7/LibraryInterface.java +9 -0
- dscc_remote_toolkit/java/q7/LibraryServer.java +17 -0
- dscc_remote_toolkit/java/q8/Client.java +23 -0
- dscc_remote_toolkit/java/q8/ImplAnirudh.java +41 -0
- dscc_remote_toolkit/java/q8/InterAnirudh.java +9 -0
- dscc_remote_toolkit/java/q8/Server.java +17 -0
- dscc_remote_toolkit/java/q9/TokenRing.java +47 -0
- dscc_remote_toolkit/runner.py +240 -0
- dscc_remote_toolkit-0.2.0.dist-info/METADATA +97 -0
- dscc_remote_toolkit-0.2.0.dist-info/RECORD +35 -0
- dscc_remote_toolkit-0.2.0.dist-info/WHEEL +5 -0
- dscc_remote_toolkit-0.2.0.dist-info/entry_points.txt +9 -0
- dscc_remote_toolkit-0.2.0.dist-info/licenses/LICENSE +21 -0
- dscc_remote_toolkit-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package library_rmi;
|
|
2
|
+
|
|
3
|
+
import java.rmi.registry.LocateRegistry;
|
|
4
|
+
import java.rmi.registry.Registry;
|
|
5
|
+
import java.util.List;
|
|
6
|
+
|
|
7
|
+
public class LibraryClient {
|
|
8
|
+
public static void main(String[] args) {
|
|
9
|
+
try {
|
|
10
|
+
Registry r = LocateRegistry.getRegistry("localhost", 1100);
|
|
11
|
+
LibraryInterface obj = (LibraryInterface) r.lookup("LibraryService");
|
|
12
|
+
System.out.println("--- Books from Library Database ---");
|
|
13
|
+
List<String> books = obj.getBookDetails();
|
|
14
|
+
for (String book : books) {
|
|
15
|
+
System.out.println(book);
|
|
16
|
+
}
|
|
17
|
+
} catch (Exception e) {
|
|
18
|
+
e.printStackTrace();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package library_rmi;
|
|
2
|
+
|
|
3
|
+
import java.rmi.RemoteException;
|
|
4
|
+
import java.rmi.server.UnicastRemoteObject;
|
|
5
|
+
import java.sql.Connection;
|
|
6
|
+
import java.sql.DriverManager;
|
|
7
|
+
import java.sql.ResultSet;
|
|
8
|
+
import java.sql.Statement;
|
|
9
|
+
import java.util.ArrayList;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
|
|
12
|
+
public class LibraryImpl extends UnicastRemoteObject implements LibraryInterface {
|
|
13
|
+
private Connection con;
|
|
14
|
+
|
|
15
|
+
public LibraryImpl() throws RemoteException {
|
|
16
|
+
try {
|
|
17
|
+
Class.forName("com.mysql.cj.jdbc.Driver");
|
|
18
|
+
con = DriverManager.getConnection(
|
|
19
|
+
"jdbc:mysql://localhost:3306/Library", "root", "");
|
|
20
|
+
} catch (Exception e) {
|
|
21
|
+
e.printStackTrace();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public List<String> getBookDetails() throws RemoteException {
|
|
27
|
+
List<String> books = new ArrayList<>();
|
|
28
|
+
try {
|
|
29
|
+
Statement st = con.createStatement();
|
|
30
|
+
ResultSet rs = st.executeQuery("SELECT Book_id, Book_name, Book_author FROM Book");
|
|
31
|
+
while (rs.next()) {
|
|
32
|
+
books.add(
|
|
33
|
+
rs.getString("Book_id") + " | "
|
|
34
|
+
+ rs.getString("Book_name") + " | "
|
|
35
|
+
+ rs.getString("Book_author"));
|
|
36
|
+
}
|
|
37
|
+
} catch (Exception e) {
|
|
38
|
+
e.printStackTrace();
|
|
39
|
+
}
|
|
40
|
+
return books;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package library_rmi;
|
|
2
|
+
|
|
3
|
+
import java.rmi.registry.LocateRegistry;
|
|
4
|
+
import java.rmi.registry.Registry;
|
|
5
|
+
|
|
6
|
+
public class LibraryServer {
|
|
7
|
+
public static void main(String[] args) {
|
|
8
|
+
try {
|
|
9
|
+
LibraryInterface obj = new LibraryImpl();
|
|
10
|
+
Registry r = LocateRegistry.createRegistry(1100);
|
|
11
|
+
r.rebind("LibraryService", obj);
|
|
12
|
+
System.out.println("Library RMI Server is running on port 1100...");
|
|
13
|
+
} catch (Exception e) {
|
|
14
|
+
e.printStackTrace();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package rmiproject;
|
|
2
|
+
|
|
3
|
+
import java.rmi.registry.LocateRegistry;
|
|
4
|
+
import java.rmi.registry.Registry;
|
|
5
|
+
import java.util.List;
|
|
6
|
+
|
|
7
|
+
public class Client {
|
|
8
|
+
public static void main(String[] args) {
|
|
9
|
+
try {
|
|
10
|
+
Registry r = LocateRegistry.getRegistry("localhost", 1099);
|
|
11
|
+
InterAnirudh obj = (InterAnirudh) r.lookup("BillService");
|
|
12
|
+
System.out.println("Fetching all bill details automatically...");
|
|
13
|
+
System.out.println();
|
|
14
|
+
System.out.println("--- Response from Remote Server ---");
|
|
15
|
+
List<String> bills = obj.getBillDetails();
|
|
16
|
+
for (String bill : bills) {
|
|
17
|
+
System.out.println(bill);
|
|
18
|
+
}
|
|
19
|
+
} catch (Exception e) {
|
|
20
|
+
e.printStackTrace();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package rmiproject;
|
|
2
|
+
|
|
3
|
+
import java.rmi.RemoteException;
|
|
4
|
+
import java.rmi.server.UnicastRemoteObject;
|
|
5
|
+
import java.sql.Connection;
|
|
6
|
+
import java.sql.DriverManager;
|
|
7
|
+
import java.sql.ResultSet;
|
|
8
|
+
import java.sql.Statement;
|
|
9
|
+
import java.util.ArrayList;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
|
|
12
|
+
public class ImplAnirudh extends UnicastRemoteObject implements InterAnirudh {
|
|
13
|
+
Connection con;
|
|
14
|
+
|
|
15
|
+
public ImplAnirudh() throws RemoteException {
|
|
16
|
+
try {
|
|
17
|
+
Class.forName("com.mysql.cj.jdbc.Driver");
|
|
18
|
+
con = DriverManager.getConnection(
|
|
19
|
+
"jdbc:mysql://localhost:3306/Elecrtic_Bill", "root", "");
|
|
20
|
+
} catch (Exception e) {
|
|
21
|
+
e.printStackTrace();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public List<String> getBillDetails() throws RemoteException {
|
|
26
|
+
List<String> bills = new ArrayList<>();
|
|
27
|
+
try {
|
|
28
|
+
Statement st = con.createStatement();
|
|
29
|
+
ResultSet rs = st.executeQuery("SELECT * FROM Bill");
|
|
30
|
+
while (rs.next()) {
|
|
31
|
+
bills.add(
|
|
32
|
+
rs.getString("consumer_name") + " | "
|
|
33
|
+
+ rs.getString("bill_due_date") + " | "
|
|
34
|
+
+ rs.getString("bill_amount"));
|
|
35
|
+
}
|
|
36
|
+
} catch (Exception e) {
|
|
37
|
+
e.printStackTrace();
|
|
38
|
+
}
|
|
39
|
+
return bills;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package rmiproject;
|
|
2
|
+
|
|
3
|
+
import java.rmi.registry.LocateRegistry;
|
|
4
|
+
import java.rmi.registry.Registry;
|
|
5
|
+
|
|
6
|
+
public class Server {
|
|
7
|
+
public static void main(String[] args) {
|
|
8
|
+
try {
|
|
9
|
+
InterAnirudh obj = new ImplAnirudh();
|
|
10
|
+
Registry r = LocateRegistry.createRegistry(1099);
|
|
11
|
+
r.rebind("BillService", obj);
|
|
12
|
+
System.out.println("Electric Bill RMI Server is running...");
|
|
13
|
+
} catch (Exception e) {
|
|
14
|
+
e.printStackTrace();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import java.util.Scanner;
|
|
2
|
+
|
|
3
|
+
public class TokenRing {
|
|
4
|
+
public static void main(String[] args) {
|
|
5
|
+
try (Scanner sc = new Scanner(System.in)) {
|
|
6
|
+
System.out.print("Enter the number of nodes in the ring: ");
|
|
7
|
+
int n = sc.nextInt();
|
|
8
|
+
|
|
9
|
+
System.out.print("Ring formed: ");
|
|
10
|
+
for (int i = 0; i < n; i++) {
|
|
11
|
+
System.out.print(i + " -> ");
|
|
12
|
+
}
|
|
13
|
+
System.out.println("0");
|
|
14
|
+
|
|
15
|
+
int token = 0;
|
|
16
|
+
int choice = 1;
|
|
17
|
+
while (choice == 1) {
|
|
18
|
+
System.out.print("Enter sender node (0 to " + (n - 1) + "): ");
|
|
19
|
+
int sender = sc.nextInt();
|
|
20
|
+
System.out.print("Enter receiver node (0 to " + (n - 1) + "): ");
|
|
21
|
+
int receiver = sc.nextInt();
|
|
22
|
+
System.out.print("Enter data to send: ");
|
|
23
|
+
String data = sc.next();
|
|
24
|
+
|
|
25
|
+
System.out.print("Token passing: ");
|
|
26
|
+
for (int i = token; i != sender; i = (i + 1) % n) {
|
|
27
|
+
System.out.print(i + " -> ");
|
|
28
|
+
}
|
|
29
|
+
System.out.println(sender);
|
|
30
|
+
|
|
31
|
+
System.out.println("Sender " + sender + " acquired token and enters Critical Section.");
|
|
32
|
+
System.out.println("Sender " + sender + " sending data '" + data + "'...");
|
|
33
|
+
|
|
34
|
+
for (int i = (sender + 1) % n; i != receiver; i = (i + 1) % n) {
|
|
35
|
+
System.out.println("Data '" + data + "' forwarded by node " + i);
|
|
36
|
+
}
|
|
37
|
+
System.out.println("Receiver " + receiver + " received data: '" + data + "'");
|
|
38
|
+
System.out.println("Sender " + sender + " exited Critical Section.");
|
|
39
|
+
|
|
40
|
+
token = sender;
|
|
41
|
+
|
|
42
|
+
System.out.print("Do you want to send data again? (1 = Yes, 0 = No): ");
|
|
43
|
+
choice = sc.nextInt();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"""Compile, run, and export the bundled Java DSCC lab programs (Questions 1-10)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import shutil
|
|
7
|
+
import subprocess
|
|
8
|
+
import tempfile
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from importlib.resources import as_file, files
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Iterable
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True)
|
|
16
|
+
class QuestionSpec:
|
|
17
|
+
"""Metadata and entry-point classes for a bundled Java question."""
|
|
18
|
+
|
|
19
|
+
number: int
|
|
20
|
+
folder: str
|
|
21
|
+
title: str
|
|
22
|
+
roles: dict[str, str]
|
|
23
|
+
requires_mysql: bool = False
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
QUESTIONS: dict[int, QuestionSpec] = {
|
|
27
|
+
1: QuestionSpec(
|
|
28
|
+
number=1,
|
|
29
|
+
folder="q1",
|
|
30
|
+
title="Server Calculator using RPC (Datagram)",
|
|
31
|
+
roles={"server": "CalcDatagramServer", "client": "CalcDatagramClient"},
|
|
32
|
+
),
|
|
33
|
+
2: QuestionSpec(
|
|
34
|
+
number=2,
|
|
35
|
+
folder="q2",
|
|
36
|
+
title="Date Time Server using RPC (Datagram)",
|
|
37
|
+
roles={"server": "DateTimeDatagramServer", "client": "DateTimeDatagramClient"},
|
|
38
|
+
),
|
|
39
|
+
3: QuestionSpec(
|
|
40
|
+
number=3,
|
|
41
|
+
folder="q3",
|
|
42
|
+
title="Server Calculator using RPC (ServerSocket)",
|
|
43
|
+
roles={"server": "CalcSocketServer", "client": "CalcSocketClient"},
|
|
44
|
+
),
|
|
45
|
+
4: QuestionSpec(
|
|
46
|
+
number=4,
|
|
47
|
+
folder="q4",
|
|
48
|
+
title="Date Time Server using RPC (ServerSocket)",
|
|
49
|
+
roles={"server": "DateTimeSocketServer", "client": "DateTimeSocketClient"},
|
|
50
|
+
),
|
|
51
|
+
5: QuestionSpec(
|
|
52
|
+
number=5,
|
|
53
|
+
folder="q5",
|
|
54
|
+
title="Day, Time & Date Server using JDBC and RMI",
|
|
55
|
+
roles={
|
|
56
|
+
"server": "datetime_rmi.DateTimeRMIServer",
|
|
57
|
+
"client": "datetime_rmi.DateTimeRMIClient",
|
|
58
|
+
},
|
|
59
|
+
requires_mysql=True,
|
|
60
|
+
),
|
|
61
|
+
6: QuestionSpec(
|
|
62
|
+
number=6,
|
|
63
|
+
folder="q6",
|
|
64
|
+
title="Equation Solver using Datagram",
|
|
65
|
+
roles={"server": "DatagramServer", "client": "DatagramClient"},
|
|
66
|
+
),
|
|
67
|
+
7: QuestionSpec(
|
|
68
|
+
number=7,
|
|
69
|
+
folder="q7",
|
|
70
|
+
title="Library Book Info using MySQL and RMI",
|
|
71
|
+
roles={
|
|
72
|
+
"server": "library_rmi.LibraryServer",
|
|
73
|
+
"client": "library_rmi.LibraryClient",
|
|
74
|
+
},
|
|
75
|
+
requires_mysql=True,
|
|
76
|
+
),
|
|
77
|
+
8: QuestionSpec(
|
|
78
|
+
number=8,
|
|
79
|
+
folder="q8",
|
|
80
|
+
title="Electric Bill Info using MySQL and RMI",
|
|
81
|
+
roles={"server": "rmiproject.Server", "client": "rmiproject.Client"},
|
|
82
|
+
requires_mysql=True,
|
|
83
|
+
),
|
|
84
|
+
9: QuestionSpec(
|
|
85
|
+
number=9,
|
|
86
|
+
folder="q9",
|
|
87
|
+
title="Mutual Exclusion using Token Ring Algorithm",
|
|
88
|
+
roles={"main": "TokenRing"},
|
|
89
|
+
),
|
|
90
|
+
10: QuestionSpec(
|
|
91
|
+
number=10,
|
|
92
|
+
folder="q10",
|
|
93
|
+
title="Bully Election Algorithm",
|
|
94
|
+
roles={"main": "BullyElection"},
|
|
95
|
+
),
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def get_question_spec(question_number: int) -> QuestionSpec:
|
|
100
|
+
"""Return the QuestionSpec for 1..10 or raise ValueError."""
|
|
101
|
+
if question_number not in QUESTIONS:
|
|
102
|
+
raise ValueError(f"Question {question_number} not found. Valid range: 1-10.")
|
|
103
|
+
return QUESTIONS[question_number]
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def list_questions() -> list[QuestionSpec]:
|
|
107
|
+
"""Return all questions ordered 1 through 10."""
|
|
108
|
+
return [QUESTIONS[i] for i in sorted(QUESTIONS)]
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _ensure_java_tool(tool: str) -> str:
|
|
112
|
+
path = shutil.which(tool)
|
|
113
|
+
if not path:
|
|
114
|
+
raise RuntimeError(
|
|
115
|
+
f"'{tool}' was not found on PATH. Please install a JDK (Java 11+) and try again."
|
|
116
|
+
)
|
|
117
|
+
return path
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _default_build_dir(folder: str) -> Path:
|
|
121
|
+
build_dir = Path(tempfile.gettempdir()) / "dscc_remote_toolkit_classes" / folder
|
|
122
|
+
build_dir.mkdir(parents=True, exist_ok=True)
|
|
123
|
+
return build_dir
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def compile_question(question_number: int, output_dir: Path | None = None) -> Path:
|
|
127
|
+
"""Compile all .java files for a given question (1-10) and return the classes dir."""
|
|
128
|
+
spec = get_question_spec(question_number)
|
|
129
|
+
javac = _ensure_java_tool("javac")
|
|
130
|
+
target_dir = output_dir or _default_build_dir(spec.folder)
|
|
131
|
+
target_dir.mkdir(parents=True, exist_ok=True)
|
|
132
|
+
|
|
133
|
+
pkg_dir = files("dscc_remote_toolkit").joinpath("java", spec.folder)
|
|
134
|
+
with as_file(pkg_dir) as src_path:
|
|
135
|
+
java_files = sorted(str(p) for p in Path(src_path).glob("*.java"))
|
|
136
|
+
if not java_files:
|
|
137
|
+
raise FileNotFoundError(f"No .java files found for question {question_number}.")
|
|
138
|
+
subprocess.run([javac, "-d", str(target_dir), *java_files], check=True)
|
|
139
|
+
return target_dir
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _build_classpath(classes_dir: Path, mysql_jar: str | None = None) -> str:
|
|
143
|
+
jar = mysql_jar or os.environ.get("MYSQL_CONNECTOR_JAR")
|
|
144
|
+
if jar:
|
|
145
|
+
return f"{classes_dir}{os.pathsep}{jar}"
|
|
146
|
+
return str(classes_dir)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def run_question(
|
|
150
|
+
question_number: int,
|
|
151
|
+
role: str | None = None,
|
|
152
|
+
mysql_jar: str | None = None,
|
|
153
|
+
build_dir: Path | None = None,
|
|
154
|
+
) -> int:
|
|
155
|
+
"""Compile and run a specific question role ('server', 'client', or 'main')."""
|
|
156
|
+
spec = get_question_spec(question_number)
|
|
157
|
+
chosen_role = role or ("main" if "main" in spec.roles else "server")
|
|
158
|
+
if chosen_role not in spec.roles:
|
|
159
|
+
valid = ", ".join(spec.roles.keys())
|
|
160
|
+
raise ValueError(
|
|
161
|
+
f"Invalid role {chosen_role!r} for Question {question_number}. Choose from: {valid}"
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
java = _ensure_java_tool("java")
|
|
165
|
+
classes_dir = compile_question(question_number, output_dir=build_dir)
|
|
166
|
+
classpath = _build_classpath(classes_dir, mysql_jar=mysql_jar)
|
|
167
|
+
main_class = spec.roles[chosen_role]
|
|
168
|
+
completed = subprocess.run([java, "-cp", classpath, main_class])
|
|
169
|
+
return completed.returncode
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def start_question_process(
|
|
173
|
+
question_number: int,
|
|
174
|
+
role: str | None = None,
|
|
175
|
+
mysql_jar: str | None = None,
|
|
176
|
+
build_dir: Path | None = None,
|
|
177
|
+
) -> subprocess.Popen[str]:
|
|
178
|
+
"""Compile and start a question's Java process in the background."""
|
|
179
|
+
spec = get_question_spec(question_number)
|
|
180
|
+
chosen_role = role or ("main" if "main" in spec.roles else "server")
|
|
181
|
+
if chosen_role not in spec.roles:
|
|
182
|
+
valid = ", ".join(spec.roles.keys())
|
|
183
|
+
raise ValueError(
|
|
184
|
+
f"Invalid role {chosen_role!r} for Question {question_number}. Choose from: {valid}"
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
java = _ensure_java_tool("java")
|
|
188
|
+
classes_dir = compile_question(question_number, output_dir=build_dir)
|
|
189
|
+
classpath = _build_classpath(classes_dir, mysql_jar=mysql_jar)
|
|
190
|
+
main_class = spec.roles[chosen_role]
|
|
191
|
+
return subprocess.Popen(
|
|
192
|
+
[java, "-cp", classpath, main_class],
|
|
193
|
+
stdin=subprocess.PIPE,
|
|
194
|
+
stdout=subprocess.PIPE,
|
|
195
|
+
stderr=subprocess.PIPE,
|
|
196
|
+
text=True,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def download_question(
|
|
201
|
+
question_numbers: int | Iterable[int] | None = None,
|
|
202
|
+
destination: str | Path = "./dscc_questions",
|
|
203
|
+
) -> Path:
|
|
204
|
+
"""Export one, several, or all (1-10) bundled Java questions to destination."""
|
|
205
|
+
if question_numbers is None:
|
|
206
|
+
targets = list(range(1, 11))
|
|
207
|
+
elif isinstance(question_numbers, int):
|
|
208
|
+
targets = [question_numbers]
|
|
209
|
+
else:
|
|
210
|
+
targets = list(question_numbers)
|
|
211
|
+
|
|
212
|
+
dest = Path(destination)
|
|
213
|
+
dest.mkdir(parents=True, exist_ok=True)
|
|
214
|
+
for num in targets:
|
|
215
|
+
spec = get_question_spec(num)
|
|
216
|
+
pkg_dir = files("dscc_remote_toolkit").joinpath("java", spec.folder)
|
|
217
|
+
with as_file(pkg_dir) as src_path:
|
|
218
|
+
shutil.copytree(src_path, dest / spec.folder, dirs_exist_ok=True)
|
|
219
|
+
return dest
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
# Backward-compatible convenience helpers for Q6 and Q8
|
|
223
|
+
def run_bill_server(mysql_jar: str | None = None) -> int:
|
|
224
|
+
return run_question(8, role="server", mysql_jar=mysql_jar)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def run_bill_client(mysql_jar: str | None = None) -> int:
|
|
228
|
+
return run_question(8, role="client", mysql_jar=mysql_jar)
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def run_equation_server() -> int:
|
|
232
|
+
return run_question(6, role="server")
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def run_equation_client() -> int:
|
|
236
|
+
return run_question(6, role="client")
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def export_java_sources(destination: str | Path = "./java_sources") -> Path:
|
|
240
|
+
return download_question(None, destination=destination)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dscc-remote-toolkit
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: PyPI-ready Python package bundling and running DSCC Java lab programs (Questions 1-10)
|
|
5
|
+
Author: Anirudh
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: java,rmi,datagram,udp,socket,mysql,token-ring,election,distributed-systems
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Education
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
21
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
22
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# dscc-remote-toolkit
|
|
26
|
+
|
|
27
|
+
A PyPI-ready Python package that bundles **10 Distributed Systems & Cloud Computing (DSCC) Java programs** in order (`1–10`), allowing you to list, download/export any specific question, or compile and run them directly via `javac` / `java`.
|
|
28
|
+
|
|
29
|
+
## Included Questions (1–10)
|
|
30
|
+
|
|
31
|
+
1. **Server Calculator using RPC (Datagram / UDP)** (`q1`)
|
|
32
|
+
2. **Date Time Server using RPC (Datagram / UDP)** (`q2`)
|
|
33
|
+
3. **Server Calculator using RPC (ServerSocket / TCP)** (`q3`)
|
|
34
|
+
4. **Date Time Server using RPC (ServerSocket / TCP)** (`q4`)
|
|
35
|
+
5. **Day, Time & Date Server using JDBC and RMI** (`q5`) `[MySQL]`
|
|
36
|
+
6. **Equation Solver `(a - b)^2` using Datagram** (`q6`)
|
|
37
|
+
7. **Library Book Info (`Library.Book`) using MySQL and RMI** (`q7`) `[MySQL]`
|
|
38
|
+
8. **Electric Bill Info (`Elecrtic_Bill.Bill`) using MySQL and RMI** (`q8`) `[MySQL]`
|
|
39
|
+
9. **Mutual Exclusion using Token Ring Algorithm** (`q9`)
|
|
40
|
+
10. **Bully Election Algorithm** (`q10`)
|
|
41
|
+
|
|
42
|
+
## Prerequisites
|
|
43
|
+
|
|
44
|
+
- **Python 3.9+**
|
|
45
|
+
- **Java JDK (11+)** with `javac` and `java` on `PATH`
|
|
46
|
+
- For MySQL questions (`5`, `7`, `8`): MySQL server + `mysql-connector-j` JAR
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install dscc-remote-toolkit
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
### List all questions (1–10)
|
|
57
|
+
```bash
|
|
58
|
+
dscc-list
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Download only the question(s) you want
|
|
62
|
+
```bash
|
|
63
|
+
# Download Question 3 only
|
|
64
|
+
dscc-get 3
|
|
65
|
+
|
|
66
|
+
# Download Questions 1, 6, and 8 into ./my_lab
|
|
67
|
+
dscc-get 1 6 8 -o ./my_lab
|
|
68
|
+
|
|
69
|
+
# Download all 10 questions
|
|
70
|
+
dscc-get all
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Compile and run any question directly
|
|
74
|
+
```bash
|
|
75
|
+
# Terminal 1 (Server)
|
|
76
|
+
dscc-run 1 server
|
|
77
|
+
|
|
78
|
+
# Terminal 2 (Client)
|
|
79
|
+
dscc-run 1 client
|
|
80
|
+
|
|
81
|
+
# Standalone algorithm (Q9 Token Ring, Q10 Bully Election)
|
|
82
|
+
dscc-run 9
|
|
83
|
+
dscc-run 10
|
|
84
|
+
|
|
85
|
+
# MySQL + RMI questions (Q5, Q7, Q8)
|
|
86
|
+
dscc-run 8 server --mysql-jar /path/to/mysql-connector-j.jar
|
|
87
|
+
dscc-run 8 client
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Building & Uploading to PyPI
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
python -m build
|
|
94
|
+
python -m twine check dist/*
|
|
95
|
+
python -m twine upload --repository testpypi dist/*
|
|
96
|
+
python -m twine upload dist/*
|
|
97
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
dscc_remote_toolkit/__init__.py,sha256=tjvk7DKBLrQOIHbp-XgnE5R-1RxYTXYYpzVJr-S0tqs,733
|
|
2
|
+
dscc_remote_toolkit/cli.py,sha256=L7NLmAOvu5__QSeXoLXLHVQ0JzhbcvDQaBvY6J5TLec,4004
|
|
3
|
+
dscc_remote_toolkit/runner.py,sha256=3RtGVl1DGM8nFBlToZy8g5rVmxNtejeDSD9O_VH8BvU,7891
|
|
4
|
+
dscc_remote_toolkit/java/q1/CalcDatagramClient.java,sha256=jVgt_DJMzwOfEKaO7WGyiIltHMr0xCFQ87mfm_6y80g,1543
|
|
5
|
+
dscc_remote_toolkit/java/q1/CalcDatagramServer.java,sha256=lJIW-H1MzKlGp1gKc98Uh5oHOJbaQuanwXRgO-ZLpmc,2449
|
|
6
|
+
dscc_remote_toolkit/java/q10/BullyElection.java,sha256=MUZTmqLf_pUKi8lXa3UMvKlInZTDysY9ouG7hyBahXQ,2336
|
|
7
|
+
dscc_remote_toolkit/java/q2/DateTimeDatagramClient.java,sha256=tpsE8whUEYnOnIH2ROPi6J3ZmY3b_CkDVoMXdhoXpEY,1088
|
|
8
|
+
dscc_remote_toolkit/java/q2/DateTimeDatagramServer.java,sha256=bZi9UySpfE0zCP4FQLRglYmAvFrWWB8mQ9XKUu9mUqM,1492
|
|
9
|
+
dscc_remote_toolkit/java/q3/CalcSocketClient.java,sha256=hzGa4U1i9yWBy8m5_n55I5UMATYcx2avn4PzoLNXTPg,1172
|
|
10
|
+
dscc_remote_toolkit/java/q3/CalcSocketServer.java,sha256=jW3t_5DyNA7HkCyc8m4IYxxHmsZsHdARVRgZ7K4_oJE,2328
|
|
11
|
+
dscc_remote_toolkit/java/q4/DateTimeSocketClient.java,sha256=TBekmUflIDt4T4d9a2_-q-hmWOgeaRpk0yPPDjdV1X8,606
|
|
12
|
+
dscc_remote_toolkit/java/q4/DateTimeSocketServer.java,sha256=hmBCxbhWSw8-jgvBeuYXAiHA6RuECy4ABtC6hTKQz0E,996
|
|
13
|
+
dscc_remote_toolkit/java/q5/DateTimeRMIClient.java,sha256=SsGE8h2JClLD6Afj9U9aTthgnqeeShIYgTXuoB-97bw,737
|
|
14
|
+
dscc_remote_toolkit/java/q5/DateTimeRMIImpl.java,sha256=2HMopCmJ-niJAo8WfUFfAv7JurXNsLDYEpvUcGzPl2k,1413
|
|
15
|
+
dscc_remote_toolkit/java/q5/DateTimeRMIInterface.java,sha256=UuCauE8CF9uDN4GJAENJnLBvwXRB7dHJ0QPqFt-uLJg,290
|
|
16
|
+
dscc_remote_toolkit/java/q5/DateTimeRMIServer.java,sha256=8D9Y46xIjrLJvgqFUjXvnQqmqgJhORP8JS2mVJtF8Fw,534
|
|
17
|
+
dscc_remote_toolkit/java/q6/DatagramClient.java,sha256=QtSMGPTHoMSMwW8VEEO7eG4RuJy8XH_3QhlZbH39E4U,1453
|
|
18
|
+
dscc_remote_toolkit/java/q6/DatagramServer.java,sha256=QLILwdt7JO04xEpTGQNBd_E-ENqIwJPxCgDkjDel9uA,1660
|
|
19
|
+
dscc_remote_toolkit/java/q6/EquationImplAnirudh.java,sha256=DADw0BbhwqnPuz1Y3g3iFqNmNHME9PnhdWE03Oou7xk,242
|
|
20
|
+
dscc_remote_toolkit/java/q6/EquationInterfaceAnirudh.java,sha256=dVtHWjq9X69XqtUnHYEWwq7tqxyUCQPOToCv9cEvqrw,93
|
|
21
|
+
dscc_remote_toolkit/java/q7/LibraryClient.java,sha256=KUoENXRfQ64MI67RylH6rOrBgivLh796pnqJPpGRIG8,669
|
|
22
|
+
dscc_remote_toolkit/java/q7/LibraryImpl.java,sha256=WkOXfQGJcY3oaigbb0jH-FL-7UI7AwgyuCDQeTqAZyE,1350
|
|
23
|
+
dscc_remote_toolkit/java/q7/LibraryInterface.java,sha256=BYZUxIxfOeA0vygLcIwfUk-ELFqkrcCFukVxoCLNWcQ,214
|
|
24
|
+
dscc_remote_toolkit/java/q7/LibraryServer.java,sha256=F6pa-XysL5fEWXVwcvRAclCF7hKQZ2glWLJUwsI2-7U,512
|
|
25
|
+
dscc_remote_toolkit/java/q8/Client.java,sha256=HM7GNcM1brPPQ43dhd4PNzKHR4KCV2Znti3t67AIjjA,762
|
|
26
|
+
dscc_remote_toolkit/java/q8/ImplAnirudh.java,sha256=i5S7jeTd8gFlyA_jQKqkTMjwKahMcri3as2q_W2UkmM,1309
|
|
27
|
+
dscc_remote_toolkit/java/q8/InterAnirudh.java,sha256=4xSp8fAsiTYe5_GX0BwGJKvpHzmRM-dwORPghcTtYDg,209
|
|
28
|
+
dscc_remote_toolkit/java/q8/Server.java,sha256=cd2ww6DONjOTwJb_TzB0MpPKV15qpIUhdlVXdlJVM6U,490
|
|
29
|
+
dscc_remote_toolkit/java/q9/TokenRing.java,sha256=hT8Ja1SQC2L8kTm0nfjYjd8ZBHhWTG8RfBZOeACvEyk,1875
|
|
30
|
+
dscc_remote_toolkit-0.2.0.dist-info/licenses/LICENSE,sha256=L9cVb3RemGE1aCx5ioN5h_gl_yBqhxOqoDPp5S9PW4E,1064
|
|
31
|
+
dscc_remote_toolkit-0.2.0.dist-info/METADATA,sha256=4ci8ry3Nun0OVwtLDvSOd3j1ohbIFZfk2Ctvjdi17oQ,2961
|
|
32
|
+
dscc_remote_toolkit-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
33
|
+
dscc_remote_toolkit-0.2.0.dist-info/entry_points.txt,sha256=0JosEjpt9x5CZfAoTbnNSt9yDKDxOMKGVzqHeei3jSE,464
|
|
34
|
+
dscc_remote_toolkit-0.2.0.dist-info/top_level.txt,sha256=0yV6bodPpZx5G3i6Yw1BHq0r-TZWHA1hLbLM5U43k7E,20
|
|
35
|
+
dscc_remote_toolkit-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
bill-client = dscc_remote_toolkit.cli:run_bill_client
|
|
3
|
+
bill-server = dscc_remote_toolkit.cli:run_bill_server
|
|
4
|
+
dscc-get = dscc_remote_toolkit.cli:cmd_download_question
|
|
5
|
+
dscc-list = dscc_remote_toolkit.cli:cmd_list_questions
|
|
6
|
+
dscc-run = dscc_remote_toolkit.cli:cmd_run_question
|
|
7
|
+
equation-client = dscc_remote_toolkit.cli:run_equation_client
|
|
8
|
+
equation-server = dscc_remote_toolkit.cli:run_equation_server
|
|
9
|
+
export-java = dscc_remote_toolkit.cli:export_java
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anirudh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dscc_remote_toolkit
|