Skip to content

Commit

Permalink
removed updates(), corrected the getPackageManager(), added a version…
Browse files Browse the repository at this point in the history
… flag
  • Loading branch information
ahmed-al-balochi committed Apr 6, 2022
1 parent b4364ca commit 9c67b3b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 34 deletions.
40 changes: 7 additions & 33 deletions LibreGaming/LibreGaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,21 @@ def __init__(self):
self.Fedora_Object = Fedora()
self.OpenSUSE_Object = OpenSUSE()
self.Ubuntu_Object = Ubuntu()
self.Common_Pkgs_Object = Common_Pkgs()

# Checking if there is a new version of LibreGaming
self.isLatestVersion()

def isLatestVersion(self):
pkgName = "LibreGaming"
print("Checking for updates, please wait...")
# Get the currently installed version
current_version = ''
for requirement in freeze(local_only=False):
pkg = requirement.split('==')
if pkg[0] == pkgName:
current_version = pkg[1]
# Check pypi for the latest version number
contents = urllib.request.urlopen('https://pypi.org/pypi/'+pkgName+'/json').read()
data = json.loads(contents)
latest_version = data['info']['version']
if latest_version != current_version:
self.whoami(True)
update = input("Your LibreGaming version is old, do you want to update?[Y/n]: ")
if update.upper() == "Y" or update.upper() == "YES":
subprocess.run(["pip", "install", "LibreGaming", "-U"])
else:
print("Declined update!\n")
else:
print("You are up to date.\n")
self.Common_Pkgs_Object = Common_Pkgs()

# Gets the package manager by running $(command -v dnf)
def getPackageManager(self):
if subprocess.getoutput("$(command -v dnf)"):
if subprocess.getoutput("command -v dnf"):
self.PackageManager = "dnf"
elif subprocess.getoutput("$(command -v yay)"):
elif subprocess.getoutput("command -v yay"):
self.PackageManager = "yay"
elif subprocess.getoutput("$(command -v paru)"):
elif subprocess.getoutput("command -v paru"):
self.PackageManager = "paru"
elif subprocess.getoutput("$(command -v pacman)"):
elif subprocess.getoutput("command -v pacman"):
self.PackageManager = "pacman"
elif subprocess.getoutput("$(command -v apt)"):
elif subprocess.getoutput("command -v apt"):
self.PackageManager = "apt"
elif subprocess.getoutput("$(command -v zypper)"):
elif subprocess.getoutput("command -v zypper"):
self.PackageManager = "zypper"
else:
print("Could not know your distro based on your Package Manager!")
Expand Down
1 change: 1 addition & 0 deletions LibreGaming/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def parse_arguments():
parser.add_argument('--minigalaxy', action='store_true', help='Install Minigalaxy Launcher')
parser.add_argument('--itch', action='store_true', help='Install itch.io Launcher')
parser.add_argument('--stl', action='store_true', help='Install Steam Tinker Launch(For Arch Linux only)')
parser.add_argument('-v','--version', action='version', version='0.2.2.3')
return parser.parse_args()

# Main execution
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = LibreGaming
version = 0.2.3.2
version = 0.2.3.4
description = Install Gaming Packages with ease
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit 9c67b3b

Please sign in to comment.