iss-tracker-cli 0.2.1__tar.gz → 0.2.3__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.
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/PKG-INFO +1 -1
- iss_tracker_cli-0.2.3/iss_tracker/__init__.py +0 -0
- iss_tracker_cli-0.2.3/iss_tracker/main.py +139 -0
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/iss_tracker_cli.egg-info/PKG-INFO +1 -1
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/iss_tracker_cli.egg-info/SOURCES.txt +2 -0
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/pyproject.toml +2 -2
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/LICENSE +0 -0
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/README.md +0 -0
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/iss_tracker_cli.egg-info/dependency_links.txt +0 -0
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/iss_tracker_cli.egg-info/entry_points.txt +0 -0
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/iss_tracker_cli.egg-info/requires.txt +0 -0
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/iss_tracker_cli.egg-info/top_level.txt +0 -0
- {iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/setup.cfg +0 -0
|
File without changes
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#gets the number of people in space
|
|
6
|
+
def getPeopData() -> int | None:
|
|
7
|
+
api = "http://api.open-notify.org/astros.json"
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
raw_data = (requests.get(api, timeout = 5)).json()
|
|
11
|
+
|
|
12
|
+
except requests.exceptions.RequestException as e:
|
|
13
|
+
print(f"Error: {e}\n")
|
|
14
|
+
return None
|
|
15
|
+
|
|
16
|
+
if "number" not in raw_data:
|
|
17
|
+
print("Unexpected API response format")
|
|
18
|
+
return None
|
|
19
|
+
|
|
20
|
+
num = raw_data["number"]
|
|
21
|
+
|
|
22
|
+
return num
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
#gets postion data of the ISS
|
|
26
|
+
def getPosData() -> tuple[str, str] | None:
|
|
27
|
+
api = "http://api.open-notify.org/iss-now.json"
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
raw_data = (requests.get(api, timeout = 5)).json()
|
|
31
|
+
|
|
32
|
+
except requests.exceptions.RequestException as e:
|
|
33
|
+
print(f"Error: {e}\n")
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
if "iss_position" not in raw_data:
|
|
37
|
+
print("Unexpected API response format")
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
lat = raw_data["iss_position"]["latitude"]
|
|
41
|
+
lon = raw_data["iss_position"]["longitude"]
|
|
42
|
+
|
|
43
|
+
return (lat, lon)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
#help command
|
|
47
|
+
def help():
|
|
48
|
+
return '''\nCOMMAND LIST:
|
|
49
|
+
help - Lists all commands.
|
|
50
|
+
|
|
51
|
+
track {parameter}
|
|
52
|
+
{-t} - Returns position data for the ISS until interrupted.
|
|
53
|
+
{[num]} - Returns position data for the ISS [num] times.
|
|
54
|
+
|
|
55
|
+
people - Returns the number of people that are currently in space.
|
|
56
|
+
'''
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
#track command
|
|
60
|
+
def track(par):
|
|
61
|
+
if par == "-t":
|
|
62
|
+
print("\n!Displaying Position Data for infinite requests.\n")
|
|
63
|
+
try:
|
|
64
|
+
while True:
|
|
65
|
+
data = getPosData()
|
|
66
|
+
if data != None:
|
|
67
|
+
lat, lon = data
|
|
68
|
+
print(f"------ISS position------\nLatitude: {lat}\nLongitude: {lon}\n")
|
|
69
|
+
time.sleep(1)
|
|
70
|
+
except KeyboardInterrupt:
|
|
71
|
+
print("\nExiting...\n")
|
|
72
|
+
else:
|
|
73
|
+
try:
|
|
74
|
+
t = int(par)
|
|
75
|
+
print(f"\n!Displaying Position Data for {t} request(s).\n")
|
|
76
|
+
for i in range(t):
|
|
77
|
+
data = getPosData()
|
|
78
|
+
if data != None:
|
|
79
|
+
lat, lon = data
|
|
80
|
+
print(f"------ISS position------\nLatitude: {lat}\nLongitude: {lon}\n")
|
|
81
|
+
time.sleep(1)
|
|
82
|
+
except ValueError:
|
|
83
|
+
print("Error: Incorrect parameters")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
#people command
|
|
87
|
+
def people():
|
|
88
|
+
data = getPeopData()
|
|
89
|
+
if data != None:
|
|
90
|
+
print(f"\nThere are currently {data} people in space!\n")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
#main Program
|
|
94
|
+
def main():
|
|
95
|
+
print('''\033[34m
|
|
96
|
+
ooo
|
|
97
|
+
/ : \\
|
|
98
|
+
_____"~~~~~"_____
|
|
99
|
+
\\+##|U *^* U|##+/
|
|
100
|
+
\\..!('ISS')!../
|
|
101
|
+
^--o| |o--^
|
|
102
|
+
+====}:^ ^ ^:{====+
|
|
103
|
+
___. .| ! |. .___
|
|
104
|
+
|####:/" " "\\:####|
|
|
105
|
+
|####=| O |=####|
|
|
106
|
+
|####>\\_____/<####|
|
|
107
|
+
‾‾‾˙ | | ˙‾‾‾
|
|
108
|
+
o o
|
|
109
|
+
\033[0m
|
|
110
|
+
* ISS Position Tracker *
|
|
111
|
+
''')
|
|
112
|
+
|
|
113
|
+
while True:
|
|
114
|
+
try:
|
|
115
|
+
command = input(">").split()
|
|
116
|
+
|
|
117
|
+
#help command
|
|
118
|
+
if len(command) == 1 and command[0] == "help":
|
|
119
|
+
print(help())
|
|
120
|
+
|
|
121
|
+
#track command
|
|
122
|
+
elif len(command) in (1,2) and command[0] == "track":
|
|
123
|
+
par = command[1] if len(command) > 1 and command[1] else 1
|
|
124
|
+
track(par)
|
|
125
|
+
|
|
126
|
+
elif len(command) == 1 and command[0] == "people":
|
|
127
|
+
people()
|
|
128
|
+
|
|
129
|
+
#invalid command
|
|
130
|
+
else:
|
|
131
|
+
print("Invalid command! Enter 'help' to display command list.")
|
|
132
|
+
|
|
133
|
+
except KeyboardInterrupt:
|
|
134
|
+
print("\nExiting...\n")
|
|
135
|
+
break
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
if __name__ == "__main__":
|
|
139
|
+
main()
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "iss-tracker-cli"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.3"
|
|
8
8
|
description = "CLI tool for tracking the real-time position of the International Space Station (ISS) and displaying how many people are currently in space"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -37,4 +37,4 @@ classifiers = [
|
|
|
37
37
|
iss-tracker = "iss_tracker.main:main"
|
|
38
38
|
|
|
39
39
|
[tool.setuptools]
|
|
40
|
-
|
|
40
|
+
packages = ["iss_tracker"]
|
|
File without changes
|
|
File without changes
|
{iss_tracker_cli-0.2.1 → iss_tracker_cli-0.2.3}/iss_tracker_cli.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|