iss-tracker-cli 0.1.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.
File without changes
iss_tracker/main.py ADDED
@@ -0,0 +1,119 @@
1
+ import requests
2
+ import time
3
+
4
+
5
+ def getPeopData():
6
+ api = "http://api.open-notify.org/astros.json"
7
+ try:
8
+ raw_data = (requests.get(api, timeout = 5)).json()
9
+ except requests.exceptions.RequestException as e:
10
+ print(f"Error: {e}\n")
11
+ return None
12
+
13
+ num = raw_data["number"]
14
+
15
+ return num
16
+
17
+
18
+ def getPosData():
19
+ api = "http://api.open-notify.org/iss-now.json"
20
+ try:
21
+ raw_data = (requests.get(api, timeout = 5)).json()
22
+ except requests.exceptions.RequestException as e:
23
+ print(f"Error: {e}\n")
24
+ return None
25
+
26
+ lat = raw_data["iss_position"]["latitude"]
27
+ lon = raw_data["iss_position"]["longitude"]
28
+
29
+ return (lat, lon)
30
+
31
+
32
+ def help():
33
+ return '''command list:
34
+ help - Lists all commands.
35
+ track {parameter}
36
+ {-t} - Returns position data for the ISS until interupted.
37
+ {[num]} - Returns position data for the ISS [num] times.
38
+ people - Returns the number of people that are currently in space.'''
39
+
40
+
41
+ def track(par):
42
+ if par == "-t":
43
+ print("\n!Displaying Position Data for infinite requests.\n")
44
+ try:
45
+ while True:
46
+ data = getPosData()
47
+ if data != None:
48
+ lat, lon = data
49
+ print(f"------ISS position------\nLatitude: {lat}\nLongitude: {lon}\n")
50
+ time.sleep(1)
51
+ except KeyboardInterrupt:
52
+ print("\nExiting...\n")
53
+ else:
54
+ try:
55
+ t = int(par)
56
+ print(f"\n!Displaying Position Data for {t} request(s).\n")
57
+ for i in range(t):
58
+ data = getPosData()
59
+ if data != None:
60
+ lat, lon = data
61
+ print(f"------ISS position------\nLatitude: {lat}\nLongitude: {lon}\n")
62
+ time.sleep(1)
63
+ except TypeError as e:
64
+ print("Error: Incorrect parammeters")
65
+
66
+
67
+ def people():
68
+ data = getPeopData()
69
+ if data != None:
70
+ print(f"\nThere are currently {data} people in space!\n")
71
+
72
+
73
+ #Main Programme
74
+ def main():
75
+ print('''\033[34m
76
+ ooo
77
+ / : \\
78
+ _____"~~~~~"_____
79
+ \\+##|U *^* U|##+/
80
+ \\..!('ISS')!../
81
+ ^--o| |o--^
82
+ +====}:^ ^ ^:{====+
83
+ ___. .| ! |. .___
84
+ |####:/" " "\\:####|
85
+ |####=| O |=####|
86
+ |####>\\_____/<####|
87
+ ‾‾‾˙ | | ˙‾‾‾
88
+ o o
89
+ \033[0m
90
+ * ISS Position Tracker *
91
+ ''')
92
+
93
+ while True:
94
+ try:
95
+ command = input(">").lstrip()
96
+
97
+ #help command
98
+ if command.strip() == "help":
99
+ print(help())
100
+
101
+ #track command
102
+ elif command[:5] == "track":
103
+ par = command[5:].strip()
104
+ if par == "":
105
+ par = 1
106
+ track(par)
107
+
108
+ elif command.strip() == "people":
109
+ people()
110
+
111
+ #invalid command
112
+ else:
113
+ print("!Invalid command. Enter 'help' to display command list.")
114
+ except KeyboardInterrupt:
115
+ print("\nExiting...\n")
116
+ break
117
+
118
+ if __name__ == "__main__":
119
+ main()
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: iss-tracker-cli
3
+ Version: 0.1.0
4
+ Summary: CLI tool to track ISS position
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: requests
8
+
9
+ Simple cli tool for tracking the position of the ISS in real time!
10
+
11
+ commands include:
12
+ help - Lists all commands.
13
+ track {parameter}
14
+ {-t} - Returns position data for the ISS until interupted.
15
+ {[num]} - Returns position data for the ISS [num] times.
16
+ people - Returns the number of people that are currently in space.
17
+
18
+ Hope you like it! :)
19
+
20
+
21
+ (this project uses open notify API)
@@ -0,0 +1,7 @@
1
+ iss_tracker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ iss_tracker/main.py,sha256=BmZQQbsKoqncJpbOBqwmcmsVnHReQuwKY1NDm0U_Kvo,3143
3
+ iss_tracker_cli-0.1.0.dist-info/METADATA,sha256=zmJ844dn9j7Os6sEnDMNbCHJhPuDoDRanxdYrReFiJk,593
4
+ iss_tracker_cli-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
5
+ iss_tracker_cli-0.1.0.dist-info/entry_points.txt,sha256=d2y8T5WOg6DVY5gjyv3vAVJhtkeynxdF2ppPLrjDGJg,54
6
+ iss_tracker_cli-0.1.0.dist-info/top_level.txt,sha256=Qta2H9PZW0lCsvpwde45dn8FHi3ISpyr7nbbfkvVCCA,12
7
+ iss_tracker_cli-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ iss-tracker = iss_tracker.main:main
@@ -0,0 +1 @@
1
+ iss_tracker