-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (47 loc) · 1.68 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import sys
import requests
import webbrowser
# Replace these values with your GitHub repository details
repo_owner = 'CodeSoftGit'
repo_name = 'pyterm'
python_version = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
pyterm_version = 1.0
def get_latest_release_version():
url = f'https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest'
response = requests.get(url)
if response.status_code == 200:
data = response.json()
latest_version = data['tag_name']
return latest_version
else:
print(f"Failed to fetch the latest release version. Status Code: {response.status_code}")
return None
def compare_versions(user_version, latest_version):
# Split the version strings into lists of integers
user_version_numbers = list(map(int, user_version.split('.')))
latest_version_numbers = list(map(int, latest_version.lstrip('v').split('.')))
latest_version = get_latest_release_version()
def clear():
os.system('cls' if os.name=='nt' else 'clear')
print(f"Python {python_version}")
print(f"pyterm {pyterm_version}")
try:
if float(pyterm_version) < float(latest_version):
print("A newer version is availible! Run update() to open the releases page.")
except Exception as e:
pass
print("Use help() for other commands")
def help():
print("Other commands:")
print("clear(): Clear the terminal screen")
print("help(): View other commands")
def update():
webbrowser.open("https://github.com/CodeSoftGit/pyterm")
clear()
while True:
try:
code = input("py $ ")
exec(code)
except Exception as e:
print(e)