-
Notifications
You must be signed in to change notification settings - Fork 0
/
jackettupdate.py
67 lines (56 loc) · 2.91 KB
/
jackettupdate.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
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
# This Python file uses the following encoding: utf-8
# JackettUpdate
###############################################################################################
# This script can be used to to keep Jackett for Linux automatically up to date. #
# It is setup for the X64 and ARM versions of Linux. If your distro uses systemd then #
# this script has logic that can stop and start the server if needed. If you don't have #
# systemd then if you want the server stopped and started by the script you'll need to #
# modify the commands as needed. #
# Should work with both python 2.7 and all flavors of 3. #
###############################################################################################
# Sets the version # for the command line -v/--version response
versionnum = "2.0 Beta"
app = "JackettUpdate: "
if __name__ == "__main__":
import sys
import os
import time
import argparse
from configparser import ConfigParser
import configparser
from timeit import default_timer as timer
# First we're going to force the working path to be where the script lives
os.chdir(sys.path[0])
# Just to make python happy
returncode = 0
# This sets up the command line arguments
parser = argparse.ArgumentParser(description="An updater for Jackett",prog='jackettupdate')
parser.add_argument('-c','--config', action='store_true', help='Runs the config updater',required=False)
parser.add_argument('-v','--version', action='version', version='%(prog)s ' + versionnum,help='Displays version number')
args = parser.parse_args()
# If the user hasn't used the -c/--config command line argument this will test to see if the config file exist. If it doesn't
# it will prompt the user to run the config tool from the command line. This only needs done once.
if args.config == False:
if not os.path.isfile("config.ini"):
print("")
print("Config file doesn't exist! Likely this is your first time running the script. Starting configuration manager.")
print("")
import modules.configupdate
# Here we update the config file if the user used the command line argument
try:
config = configparser.ConfigParser()
if args.config == True:
print("")
print("Config update started....")
print("")
import modules.configupdate
except Exception as e:
print("JackettUpdate: Couldn't call the configupdater.")
print("JackettUpdate: Here's the error we got -- " + str(e))
quit()
# Now well try and update the app if the user chose that option
from modules.configread import appupdate
if appupdate == 'True':
import modules.selfupdate
import modules.mainupdate