computercompanion 1.0.2__tar.gz

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.
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.4
2
+ Name: computercompanion
3
+ Version: 1.0.2
4
+ Summary: A python based friendly assistant filled with tools
5
+ Author: Charlie Lindsay
6
+ Requires-Python: >=3.8
7
+ Requires-Dist: pythonping
8
+ Requires-Dist: psutil
@@ -0,0 +1,33 @@
1
+ # Computer Companion
2
+ A python script that helps users access things they need faster and access information in an efficient way. Has built in tools to streamline user workflow.
3
+
4
+ ## Features
5
+ - Remembers user name
6
+ - Opening App Function
7
+ - Help Menu
8
+ - Basic Calculator
9
+ - System Information
10
+ - IPv4 automatic batch ping
11
+ - Random Number Generator
12
+ - Friendly Greetings
13
+ - Fun mode including jokes
14
+
15
+
16
+ ## Requirements
17
+ - Python installed
18
+ - Data folder prepared (should come in repo)
19
+
20
+ ### Optional
21
+ - Pythonping (install using pip install pythonping in terminal)
22
+
23
+
24
+ ## How to use
25
+ ### Running for first time
26
+ Simply run the python script after installing and preparing the requirements. It will greet you for the first time and will ask for a name. Simply type in the terminal your response, and press enter. Everything is explained in the script, and there is a help mode.
27
+ ### Changing name
28
+ Changing the name is simple, just delete the first.json and name.json files in /data and it will reprompt for the name the next time the script runs. Alternatively, you can modify the .json files to change your name or make the script think you are running it for the first time again.
29
+
30
+ ## AI Use
31
+ AI was only used for some debugging, some concepts I didn't understand, which I then recoded and implemented in. And, for the joke gathering.
32
+
33
+ Made by Charlie Lindsay during Hackclub Stardance
File without changes
@@ -0,0 +1 @@
1
+ Keeping this folder active in the github repository so the python files can be created.
@@ -0,0 +1,279 @@
1
+ """Computer Companion."""
2
+ import json
3
+ import os
4
+ import sys
5
+ import time
6
+ import ipaddress
7
+ import random
8
+ import platform
9
+ import psutil
10
+
11
+ try:
12
+ from pythonping import ping
13
+ except ImportError:
14
+ print("To use ping utilities, you need to install the pythonping "
15
+ "library. \nPlease run: pip install pythonping in your terminal.")
16
+ DEFAULT_APPS = {"Powershell": "powershell",
17
+ "Command Prompt": "cmd",
18
+ "Cmd": "cmd",
19
+ "Settings": "ms-settings:",
20
+ "Device Manager": "devmgmt.msc",
21
+ "DVM": "devmgmt.msc",
22
+ "Task Manager": "taskmgr",
23
+ "TM": "taskmgr"}
24
+ request = ""
25
+ ping_ip = []
26
+
27
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
28
+ DATA_DIR = os.path.join(BASE_DIR, "data")
29
+
30
+ def file_setup():
31
+ """Do a check if .json file exists, and if not creates them."""
32
+ first_path = os.path.join(DATA_DIR, "first.json")
33
+ name_path = os.path.join(DATA_DIR, "name.json")
34
+
35
+ if not os.path.exists(first_path):
36
+ with open(first_path, "w") as f:
37
+ json.dump(0, f)
38
+
39
+ if not os.path.exists(name_path):
40
+ with open(name_path, "w") as f:
41
+ json.dump("", f)
42
+
43
+ file_setup()
44
+
45
+
46
+ with open(os.path.join(DATA_DIR, "first.json"), "r") as f:
47
+ returning = json.load(f)
48
+
49
+ with open(os.path.join(DATA_DIR, "name.json"), "r") as f:
50
+ name = json.load(f)
51
+
52
+
53
+ def welcome_first():
54
+ print(f"\033[32m\nWelcome to Computer Companion!\033[0m")
55
+ name = input("Please enter your name: ")
56
+ with open(os.path.join(DATA_DIR, "first.json"), "w") as f:
57
+ json.dump(1, f)
58
+
59
+ with open(os.path.join(DATA_DIR, "name.json"), "w") as f:
60
+ json.dump(name, f)
61
+ print(f"\033[32mNice to meet you, {name}!\n\033[0m")
62
+
63
+
64
+ def welcome_returning(name):
65
+ WELCOME_MESSAGES = [f"Welcome back, {name}!", f"Hello again, {name}!",
66
+ f"Good to see you again, {name}!", f"Welcome back, "
67
+ f"{name}!",
68
+ f"Hey {name}, welcome back!", f"A great day to "
69
+ f"chat with you, {name}!", f"Nice to see you, {name}!"]
70
+ """Do greeting for returning user."""
71
+ print(f"\033[32m\n{WELCOME_MESSAGES[random.randint(0, len(WELCOME_MESSAGES) - 1)]}\033[0m")
72
+
73
+
74
+ def app_opener():
75
+ """Do the app opening function."""
76
+ print(f"App options: {', '.join(DEFAULT_APPS)}")
77
+ app_name = input("What app would you like to open? ").lower()
78
+ for key, value in DEFAULT_APPS.items():
79
+ if app_name == key.lower():
80
+ os.startfile(value)
81
+ print(f"Opening {value}...")
82
+ return
83
+ print("App not found.")
84
+
85
+ def ping_utility():
86
+ valid_ip_count = False
87
+ valid_ping_count = False
88
+ while not valid_ip_count:
89
+ ping_ip_counts = input("How many IP Addresses would you like to ping simultaneously? ")
90
+ try:
91
+ ping_ip_counts = int(ping_ip_counts)
92
+ if ping_ip_counts < 1 or ping_ip_counts > 32:
93
+ print("Please enter a number greater than 0 and less than or equal to 32.")
94
+ else:
95
+ valid_ip_count = True
96
+ except ValueError:
97
+ print("Please enter a valid number.")
98
+
99
+ while not valid_ping_count:
100
+ ping_times = input("How many times should I ping? ")
101
+ try:
102
+ ping_times = int(ping_times)
103
+ if ping_times < 1 or ping_times > 200:
104
+ print("Please enter a number greater than 0 and less than or equal to 200.")
105
+ else:
106
+ valid_ping_count = True
107
+ except ValueError:
108
+ print("Please enter a valid number.")
109
+
110
+ ips = []
111
+ for i in range(ping_ip_counts):
112
+ while True:
113
+ addr = input(f"Please enter IP Address {i + 1}: ")
114
+ try:
115
+ ipaddress.IPv4Address(addr)
116
+ ips.append(addr)
117
+ break
118
+ except ipaddress.AddressValueError:
119
+ print("Invalid IPv4 address. Please enter a valid IP address.")
120
+
121
+ for _ in range(ping_times):
122
+ time.sleep(1)
123
+ for addr in ips:
124
+ try:
125
+ response = ping(addr, count=1, verbose=False)
126
+ if response.success():
127
+ print(f"\033[32m\n{addr} is online!\033[0m")
128
+ else:
129
+ print(f"\033[31m\n{addr} is offline.\033[0m")
130
+ except PermissionError:
131
+ print("\n[ERROR] Pure Python ping requires Administrator/Root privileges.")
132
+ print("Please run this terminal/script as Administrator.")
133
+ return
134
+ except RuntimeError:
135
+ print(f"\n[ERROR] Could not ping {addr}. Please check the IP address and try again.")
136
+ continue
137
+
138
+ def calculator():
139
+ """Do the calculator utility."""
140
+ print("\nCalculator")
141
+ print("Select an operator. So far I can only do"
142
+ "addition, subtraction, multiplication, and division, but more"
143
+ "will be added in the future!")
144
+ operator = input("What function do you want to use? (A - Add, "
145
+ "S - Subtract, M - Multiply, D - Divide) ").lower()
146
+ if operator == "a":
147
+ num1 = float(input("Enter the first number: "))
148
+ num2 = float(input("Enter the second number: "))
149
+ print(f"The answer is: {num1 + num2}")
150
+ elif operator == "s":
151
+ num1 = float(input("Enter the first number: "))
152
+ num2 = float(input("Enter the second number: "))
153
+ print(f"The answer is: {num1 - num2}")
154
+ elif operator == "m":
155
+ num1 = float(input("Enter the first number: "))
156
+ num2 = float(input("Enter the second number: "))
157
+ print(f"The answer is: {num1 * num2}")
158
+ elif operator == "d":
159
+ num1 = float(input("Enter the first number: "))
160
+ num2 = float(input("Enter the second number: "))
161
+ if num2 == 0:
162
+ print("Cannot divide by zero.")
163
+ else:
164
+ print(f"The answer is: {num1 / num2}")
165
+
166
+
167
+ def fun():
168
+ """Do the fun utility."""
169
+ JOKES = ["Why don't eggs tell jokes? They'd crack each other up.", "I used to be a baker, but I couldn't make enough dough.", "I’m reading a book on anti‑gravity. It’s impossible to put down.", "Why did the scarecrow win an award? He was outstanding in his field.", "I don't trust stairs. They're always up to something.", "Why did the bicycle fall over? It was two‑tired.", "I used to play piano by ear, now I use my hands.", "Why can't you give Elsa a balloon? She’ll let it go.", "What do you call fake spaghetti? An impasta.", "Why did the math book look sad? Too many problems.", "I’m on a seafood diet. I see food and I eat it.", "Why don’t skeletons fight? They don’t have the guts.", "What do you call cheese that isn’t yours? Nacho cheese.", "Why did the golfer bring two pairs of pants? In case he got a hole in one.", "I used to be addicted to soap, but I’m clean now.", "Why did the tomato blush? It saw the salad dressing.", "What do you call a belt made of watches? A waist of time.", "Why don’t oysters donate to charity? They’re shellfish.", "I told my computer I needed a break, and it said 'No problem — I’ll go to sleep.'", "Why did the cookie go to the doctor? It felt crumby.", "What do you call a factory that makes OK products? A satisfactory.", "Why was the broom late? It swept in.", "Why did the coffee file a police report? It got mugged.", "I used to be a banker, but I lost interest.", "Why don’t crabs share? Because they’re shellfish.", "What do you call a sleeping bull? A bulldozer.", "Why did the chicken join a band? It had drumsticks.", "Why can’t a nose be 12 inches long? Then it’d be a foot.", "What do you call a pile of cats? A meow‑tain.", "Why did the stadium get hot? All the fans left.", "Why did the computer go to therapy? Too many tabs open.", "Why don’t melons get married? They cantaloupe.", "What do you call a fish wearing a bowtie? Sofishticated.", "Why did the man fall into the well? He couldn’t see that well.", "Why don’t vampires go to barbecues? They don’t like stakes.", "What do you call a dog magician? A labracadabrador.", "Why did the orange stop? It ran out of juice.", "Why did the photo go to jail? It was framed.", "Why did the tree get online? To log in.", "Why did the barber win the race? He took a shortcut.", "Why don’t cows have money? Farmers milk them dry.", "Why did the banana go to the doctor? It wasn’t peeling well.", "What do you call a bear with no teeth? A gummy bear.", "Why did the music teacher go to jail? She got caught with too many notes.", "Why did the fish blush? It saw the ocean’s bottom.", "Why don’t seagulls fly over the bay? Then they’d be bagels.", "Why did the calendar get nervous? Its days were numbered.", "Why did the grape stop in the middle of the road? It ran out of juice.", "Why did the belt get arrested? It held up a pair of pants.", "Why did the mushroom get invited to the party? He was a fungi.", "Why did the shovel get promoted? It was outstanding in its field.", "Why did the light bulb fail school? It wasn’t too bright.", "Why did the cow become an astronaut? To see the moooon.", "Why did the frog take the bus? His car got toad.", "Why did the cookie cry? Its mom was a wafer too long.", "Why did the lettuce win the race? It was ahead.", "Why did the pencil cross the road? It had a point.", "Why did the phone wear glasses? It lost its contacts.", "Why did the fridge blush? It saw the salad dressing.", "Why did the bee get married? He found his honey.", "Why did the clock get kicked out of class? It tocked too much.", "Why did the potato sit down? It was a little fried.", "Why did the book join the police? It had too many stories.", "Why did the candle apply for a job? It wanted to make scents.", "Why did the cloud stay home? It was feeling under the weather.", "Why did the keyboard break up with the mouse? It felt clicked on too much.", "Why did the sandwich go to the gym? To get breader.", "Why did the pirate go to school? To improve his arrr‑ticulation.", "Why did the snowman look through the carrots? He was picking his nose.", "Why did the duck get a job? He needed more bills.", "Why did the rope go to therapy? It was at the end of its rope.", "Why did the vacuum break up with the broom? It sucked at relationships.", "Why did the leaf get in trouble? It wouldn’t stop blowing.", "Why did the donut go to school? To get filled with knowledge.", "Why did the cloud get promoted? It had a silver lining.", "Why did the fish join a band? It had great scales.", "Why did the robot go on vacation? It needed to recharge.", "Why did the cookie go to school? It wanted to be a smart cookie.", "Why did the banana call the police? It got split.", "Why did the chair go to therapy? It couldn’t handle the pressure.", "Why did the squirrel bring a suitcase? It was going nuts.", "Why did the toaster break up with the bread? It felt used.", "Why did the moon skip dinner? It was full.", "Why did the spider go to school? To improve its web design.", "Why did the pencil get promoted? It was sharp.", "Why did the blanket get arrested? It covered up too much.", "Why did the cookie sit on the computer? It wanted to be a cookie file.", "Why did the chicken sit at the computer? To search for egg‑samples.", "Why did the astronaut break up with his girlfriend? He needed space.", "Why did the candle stay calm? It always kept its wick together.", "Why did the fish avoid the computer? It was scared of the net.", "Why did the grape get stepped on? It let out a little wine.", "Why did the cow buy a telescope? To see the moooon better.", "Why did the skeleton stay home? He had no body to go with."] # Gathered using AI
170
+ print(f"\033[32mYay! Good on you, {name}! You came for a laugh!\033[0m")
171
+ print(JOKES[random.randint(0, len(JOKES))])
172
+
173
+
174
+ def random_generator():
175
+ """Do the random utility."""
176
+ random_request = input("Would you like a random N - number or W -word? ").lower()
177
+ if random_request == "n":
178
+ valid = False
179
+ while valid is False:
180
+ try:
181
+ lower_bound = int(input("Enter the lower number: "))
182
+ valid = True
183
+ except ValueError:
184
+ print("\033[31mThat is not valid!\033[0m")
185
+ except TypeError:
186
+ print("\033[31mThat is not valid!\033[0m")
187
+ valid = False
188
+ while valid is False:
189
+ try:
190
+ upper_bound = int(input("Enter the upper number: "))
191
+ if upper_bound <= lower_bound:
192
+ print("\033[31mThat is not valid!\033[0m")
193
+ else:
194
+ valid = True
195
+ except ValueError:
196
+ print("\033[31mThat is not valid!\033[0m")
197
+ except TypeError:
198
+ print("\033[31mThat is not valid!\033[0m")
199
+ print(f"Your random number is: {random.randint(lower_bound, upper_bound)}")
200
+ elif random_request == "w":
201
+ valid = False
202
+ words = []
203
+ while valid is False:
204
+ try:
205
+ amount_words = int(input("How many words are you going to add? "))
206
+ if amount_words > 1:
207
+ valid = True
208
+ else:
209
+ print("\033[31mThat is not valid!\033[0m")
210
+ except ValueError:
211
+ print("\033[31mThat is not valid!\033[0m")
212
+ for i in range(amount_words):
213
+ words.append(input(f"{i+1}. Enter the word: "))
214
+ print("\n")
215
+ print(words[random.randint(0, amount_words)])
216
+ else:
217
+ print("That is not an option!")
218
+
219
+
220
+ def system_info():
221
+ print("\n###########\nSYSTEM INFO\n###########")
222
+ print(f"Machine: {platform.machine()}")
223
+ print(f"System: {platform.system()}")
224
+ print(f"Platform: {platform.platform()}")
225
+ print(f"RAM: {round(psutil.virtual_memory().total / (1024 ** 3), 2)} GB")
226
+
227
+
228
+ def utilities():
229
+ """Display other utilities."""
230
+ utility_request = ""
231
+ while utility_request != "b":
232
+ print("\nUtilities: C - Calculator, F - Fun, "
233
+ "R - Random Generators, S - System Info, P - Ping, B - Back to "
234
+ "main menu")
235
+ utility_request = input("Which utility would you"
236
+ " like to use? ").lower()
237
+ if utility_request == "p":
238
+ ping_utility()
239
+ elif utility_request == "b":
240
+ print("Returning to main menu...")
241
+ elif utility_request == "c":
242
+ calculator()
243
+ elif utility_request == "f":
244
+ fun()
245
+ elif utility_request == "r":
246
+ random_generator()
247
+ elif utility_request == "s":
248
+ system_info()
249
+ else:
250
+ print("\033[31m\nThat is not a valid command. Please enter something else.\033[0m")
251
+
252
+ """Actual program starts here."""
253
+ if returning == 1:
254
+ welcome_returning(name)
255
+ else:
256
+ welcome_first()
257
+ with open(os.path.join(DATA_DIR, "name.json"), "r") as f:
258
+ name = json.load(f)
259
+
260
+ while request != "exit" and request != "quit":
261
+ print("\nFunctions: O - Open an app, Exit - Exit the program, "
262
+ "U - Other Utilities, Help - Help menu")
263
+ request = input("What would you like to do? ").lower()
264
+ if request == "o":
265
+ app_opener()
266
+ elif request == "u":
267
+ utilities()
268
+ elif request == "help":
269
+ print("\nYou asked for help, and I will provide!"
270
+ "I am your computer companion. Tell me a"
271
+ " command, and I will do it. Here "
272
+ "are the commands you can use: "
273
+ "Functions: O - Open an app, Exit - Exit the program, "
274
+ "U - Other Utilities, Help - Help menu\nThanks for using my" \
275
+ " program! I hope you enjoy it! - Charlie")
276
+ elif request == "exit" or request == "quit":
277
+ print("Goodbye!")
278
+ else:
279
+ print("\033[31m\nThat is not a valid command. Please try again.\033[0m")
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.4
2
+ Name: computercompanion
3
+ Version: 1.0.2
4
+ Summary: A python based friendly assistant filled with tools
5
+ Author: Charlie Lindsay
6
+ Requires-Python: >=3.8
7
+ Requires-Dist: pythonping
8
+ Requires-Dist: psutil
@@ -0,0 +1,13 @@
1
+ README.md
2
+ pyproject.toml
3
+ computercompanion/__init__.py
4
+ computercompanion/main.py
5
+ computercompanion.egg-info/PKG-INFO
6
+ computercompanion.egg-info/SOURCES.txt
7
+ computercompanion.egg-info/dependency_links.txt
8
+ computercompanion.egg-info/entry_points.txt
9
+ computercompanion.egg-info/requires.txt
10
+ computercompanion.egg-info/top_level.txt
11
+ computercompanion/data/first.json
12
+ computercompanion/data/name.json
13
+ computercompanion/data/test.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ computercompanion = computercompanion.main:run
@@ -0,0 +1,2 @@
1
+ pythonping
2
+ psutil
@@ -0,0 +1 @@
1
+ computercompanion
@@ -0,0 +1,19 @@
1
+ [project]
2
+ name = "computercompanion"
3
+ version = "1.0.2"
4
+ description = "A python based friendly assistant filled with tools"
5
+ authors = [{ name = "Charlie Lindsay" }]
6
+ requires-python = ">=3.8"
7
+ dependencies = [
8
+ "pythonping",
9
+ "psutil",
10
+ ]
11
+
12
+ [project.scripts]
13
+ computercompanion = "computercompanion.main:run"
14
+
15
+ [tool.setuptools]
16
+ packages = ["computercompanion"]
17
+
18
+ [tool.setuptools.package-data]
19
+ computercompanion = ["data/*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+