diff --git a/CHANGES.md b/CHANGES.md index 6f1071ad..0b3508b9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ * Change Plex notifications to allow authenticated library updates (port from mmccurdy07/Sick-Beard) * Change Config/Notifications/Plex logo and description (adapted port from mmccurdy07/Sick-Beard) * Add ability for CSS/JS to target a specific page and layout +* Remove legacy sickbeard updater and build automation code [develop changelog] diff --git a/SickBeard.py b/SickBeard.py index 96c87f25..018bdf63 100755 --- a/SickBeard.py +++ b/SickBeard.py @@ -503,17 +503,6 @@ class SickGear(object): if install_type in ('git', 'source'): popen_list = [sys.executable, sickbeard.MY_FULLNAME] - elif install_type == 'win': - if hasattr(sys, 'frozen'): - # c:\dir\to\updater.exe 12345 c:\dir\to\sickbeard.exe - popen_list = [os.path.join(sickbeard.PROG_DIR, 'updater.exe'), str(sickbeard.PID), - sys.executable] - else: - logger.log(u"Unknown SB launch method, please file a bug report about this", logger.ERROR) - popen_list = [sys.executable, os.path.join(sickbeard.PROG_DIR, 'updater.py'), - str(sickbeard.PID), - sys.executable, - sickbeard.MY_FULLNAME] if popen_list: popen_list += sickbeard.MY_ARGS diff --git a/TODO.txt b/TODO.txt deleted file mode 100644 index ba720e0e..00000000 --- a/TODO.txt +++ /dev/null @@ -1,24 +0,0 @@ -2014-10-02 --Move the sql from the *.tmpl files --Add anidb indexer --Add supplemental data from anidb during postprocessing --Fix grabbing non-propers as propers for certain air-by-date shows --Add prefer torrents/usenet and allow custom delay between grabs from torrents/usenet --Better postprocessing handling for torrents - -2014-10-07 --Add release groups/require words/ignore words to add show page --Add 'add show and add another show' button to add show page --Change the hardcoded global ignore words to optional - -2014-10-08 --Add login page for http auth as opposed to browser dialog box - -2014-10-13 --Fix broken backlog --Fix season searches - -2014-10-21 --Remove qtip from config providers and go back to tab --Find out why superfish & supersubs js breaks provider sorting --Ability to save poster sorting and asc/desc in config diff --git a/setup.py b/setup.py deleted file mode 100644 index 7010fbef..00000000 --- a/setup.py +++ /dev/null @@ -1,282 +0,0 @@ -import re -import urllib -import ConfigParser -import sys -import os -import shutil -import zipfile -import subprocess -import fnmatch -import googlecode_upload - -from distutils.core import setup - -try: - import py2exe -except: - print "The Python module py2exe is required" - sys.exit(1) - -try: - import pygithub.github -except: - print "The Python module pyGitHub is required" - sys.exit(1) - -# mostly stolen from the SABnzbd package.py file -name = 'SickGear' -version = '0.1' - -release = name + '-' + version - -Win32ConsoleName = 'SickBeard-console.exe' -Win32WindowName = 'SickBeard.exe' - - -def findLatestBuild(): - regex = "http\://SickGear\.googlecode\.com/files/SickGear\-win32\-alpha\-build(\d+)(?:\.\d+)?\.zip" - - svnFile = urllib.urlopen("http://code.google.com/p/SickGear/downloads/list") - - for curLine in svnFile.readlines(): - match = re.search(regex, curLine) - if match: - groups = match.groups() - return int(groups[0]) - - return None - - -def recursive_find_data_files(root_dir, allowed_extensions=('*')): - to_return = {} - for (dirpath, dirnames, filenames) in os.walk(root_dir): - if not filenames: - continue - - for cur_filename in filenames: - - matches_pattern = False - for cur_pattern in allowed_extensions: - if fnmatch.fnmatch(cur_filename, '*.' + cur_pattern): - matches_pattern = True - if not matches_pattern: - continue - - cur_filepath = os.path.join(dirpath, cur_filename) - to_return.setdefault(dirpath, []).append(cur_filepath) - - return sorted(to_return.items()) - - -def find_all_libraries(root_dirs): - libs = [] - - for cur_root_dir in root_dirs: - for (dirpath, dirnames, filenames) in os.walk(cur_root_dir): - if '__init__.py' not in filenames: - continue - - libs.append(dirpath.replace(os.sep, '.')) - - return libs - - -def allFiles(dir): - files = [] - for file in os.listdir(dir): - fullFile = os.path.join(dir, file) - if os.path.isdir(fullFile): - files += allFiles(fullFile) - else: - files.append(fullFile) - - return files - -# save the original arguments and replace them with the py2exe args -oldArgs = [] -if len(sys.argv) > 1: - oldArgs = sys.argv[1:] - del sys.argv[1:] - -sys.argv.append('py2exe') - -# clear the dist dir -if os.path.isdir('dist'): - shutil.rmtree('dist') - -# root source dir -compile_dir = os.path.dirname(os.path.normpath(os.path.abspath(sys.argv[0]))) - -if not 'nopull' in oldArgs: - # pull new source from git - print 'Updating source from git' - p = subprocess.Popen('git pull origin master', shell=True, cwd=compile_dir) - o, e = p.communicate() - -# figure out what build this is going to be -latestBuild = findLatestBuild() -if 'test' in oldArgs: - currentBuildNumber = str(latestBuild) + 'a' -else: - currentBuildNumber = latestBuild + 1 - -# set up the compilation options -data_files = recursive_find_data_files('data', ['gif', 'png', 'jpg', 'ico', 'js', 'css', 'tmpl']) - -options = dict( - name=name, - version=release, - author='SickGear', - author_email='SickGear@outlook.com', - description=name + ' ' + release, - scripts=['SickBeard.py'], - packages=find_all_libraries(['sickbeard', 'lib']), -) - -# set up py2exe to generate the console app -program = [{'script': 'SickBeard.py'}] -options['options'] = {'py2exe': - { - 'bundle_files': 3, - 'packages': ['Cheetah'], - 'excludes': ['Tkconstants', 'Tkinter', 'tcl'], - 'optimize': 2, - 'compressed': 0 - } -} -options['zipfile'] = 'lib/SickGear.zip' -options['console'] = program -options['data_files'] = data_files - -# compile sickbeard-console.exe -setup(**options) - -# rename the exe to sickbeard-console.exe -try: - if os.path.exists("dist/%s" % Win32ConsoleName): - os.remove("dist/%s" % Win32ConsoleName) - os.rename("dist/%s" % Win32WindowName, "dist/%s" % Win32ConsoleName) -except: - print "Cannot create dist/%s" % Win32ConsoleName - # sys.exit(1) - -# we don't need this stuff when we make the 2nd exe -del options['console'] -del options['data_files'] -options['windows'] = program - -# compile sickbeard.exe -setup(**options) - -# compile sabToSickbeard.exe using the existing setup.py script -auto_process_dir = os.path.join(compile_dir, 'autoProcessTV') -p = subprocess.Popen([sys.executable, os.path.join(auto_process_dir, 'setup.py')], cwd=auto_process_dir, shell=True) -o, e = p.communicate() - -# copy autoProcessTV files to the dist dir -auto_process_files = ['autoProcessTV/sabToSickBeard.py', - 'autoProcessTV/hellaToSickBeard.py', - 'autoProcessTV/autoProcessTV.py', - 'autoProcessTV/autoProcessTV.cfg.sample', - 'autoProcessTV/sabToSickBeard.exe'] - -os.makedirs('dist/autoProcessTV') - -for curFile in auto_process_files: - newFile = os.path.join('dist', curFile) - print "Copying file from", curFile, "to", newFile - shutil.copy(curFile, newFile) - -# compile updater.exe -setup( - options={'py2exe': {'bundle_files': 1}}, - zipfile=None, - console=['updater.py'], requires=['Cheetah'] -) - -if 'test' in oldArgs: - print "Ignoring changelog for test build" -else: - # start building the CHANGELOG.txt - print 'Creating changelog' - gh = github.GitHub() - - # read the old changelog and find the last commit from that build - lastCommit = "" - try: - cl = open("CHANGELOG.txt", "r") - lastCommit = cl.readlines()[0].strip() - cl.close() - except: - print "I guess there's no changelog" - - newestCommit = "" - changeString = "" - - # cycle through all the git commits and save their commit messages - for curCommit in gh.commits.forBranch('SickGear', 'SickGear'): - if curCommit.id == lastCommit: - break - - if newestCommit == "": - newestCommit = curCommit.id - - changeString += curCommit.message + "\n\n" - - # if we didn't find any changes don't make a changelog file - if newestCommit != "": - newChangelog = open("CHANGELOG.txt", "w") - newChangelog.write(newestCommit + "\n\n") - newChangelog.write("Changelog for build " + str(currentBuildNumber) + "\n\n") - newChangelog.write(changeString) - newChangelog.close() - else: - print "No changes found, keeping old changelog" - -# put the changelog in the compile dir -if os.path.exists("CHANGELOG.txt"): - shutil.copy('CHANGELOG.txt', 'dist/') - -# figure out what we're going to call the zip file -print 'Zipping files...' -zipFilename = 'SickGear-win32-alpha-build' + str(currentBuildNumber) -if os.path.isfile(zipFilename + '.zip'): - zipNum = 2 - while os.path.isfile(zipFilename + '.{0:0>2}.zip'.format(str(zipNum))): - zipNum += 1 - zipFilename = zipFilename + '.{0:0>2}'.format(str(zipNum)) - -# get a list of files to add to the zip -zipFileList = allFiles('dist/') - -# add all files to the zip -z = zipfile.ZipFile(zipFilename + '.zip', 'w', zipfile.ZIP_DEFLATED) -for file in zipFileList: - z.write(file, file.replace('dist/', zipFilename + '/')) -z.close() - -print "Created zip at", zipFilename - -# i store my google code username/pw in a config so i can have this file in public source control -config = ConfigParser.ConfigParser() -configFilename = os.path.join(compile_dir, "gc.ini") -config.read(configFilename) - -gc_username = config.get("GC", "username") -gc_password = config.get("GC", "password") - -# upload to google code unless I tell it not to -if "noup" not in oldArgs and "test" not in oldArgs: - print "Uploading zip to google code" - googlecode_upload.upload(os.path.abspath(zipFilename + ".zip"), "SickGear", gc_username, gc_password, - "Win32 alpha build " + str(currentBuildNumber) + " (unstable/development release)", - ["Featured", "Type-Executable", "OpSys-Windows"]) - -if 'nopush' not in oldArgs and 'test' not in oldArgs: - # tag commit as a new build and push changes to github - print 'Tagging commit and pushing' - p = subprocess.Popen('git tag -a "build-' + str(currentBuildNumber) + '" -m "Windows build ' + zipFilename + '"', - shell=True, cwd=compile_dir) - o, e = p.communicate() - p = subprocess.Popen('git push --tags origin windows_binaries', shell=True, cwd=compile_dir) - o, e = p.communicate() diff --git a/updater.py b/updater.py deleted file mode 100644 index 07644a6e..00000000 --- a/updater.py +++ /dev/null @@ -1,96 +0,0 @@ -import subprocess, os, time, sys, os.path, shutil, re - -try: - log_file = open('sb-update.log', 'w') -except: - print "Unable to open sb-update.log, not saving output" - log_file = None - -def log(string): - if log_file: - log_file.write(string+'\n') - print string - -def isProcRunning(pid): - """See if a pid is running or not""" - - tasklist_cmd = 'tasklist /FI "PID eq '+str(pid)+'" /FO CSV' - - p = subprocess.Popen(tasklist_cmd, stdout=subprocess.PIPE) - out, err = p.communicate() - - results = out.split('\r\n') - - regex = '".*\\.exe","'+str(pid)+'",("[^"]*",?){3}' - - for cur_line in results: - if re.match(regex, cur_line, re.I): - return True - - return False - -if len(sys.argv) < 3: - log("Invalid call.") - sys.exit() - -try: - - # this should be retrieved from sys.args - pid = sys.argv[1] - - # process to re-launch - sb_executable = sys.argv[2:] - - sb_closed = False - - # try 15 times to make sure it's closed - for i in range(15): - isRunning = isProcRunning(pid) - if isRunning: - time.sleep(5) - continue - else: - sb_closed = True - break - - if not sb_closed: - log("SickGear didn't close, unable to update. You'll have to manually restart it.") - sys.exit() - - sb_root = os.path.dirname(sb_executable[0]) - sb_update_dir = os.path.join(sb_root, 'sb-update') - - # do the update if applicable - if os.path.isdir(sb_update_dir): - # find update dir name - update_dir_contents = os.listdir(sb_update_dir) - if len(update_dir_contents) != 1: - log("Invalid update data, update failed.") - sys.exit() - content_dir = os.path.join(sb_update_dir, update_dir_contents[0]) - - # copy everything from sb_update_dir to sb_root - for dirname, dirnames, filenames in os.walk(content_dir): - dirname = dirname[len(content_dir)+1:] - for curfile in filenames: - if curfile == 'updater.exe': - continue - old_path = os.path.join(content_dir, dirname, curfile) - new_path = os.path.join(sb_root, dirname, curfile) - - if os.path.isfile(new_path): - os.remove(new_path) - os.renames(old_path, new_path) - - if os.path.isdir(sb_update_dir): - shutil.rmtree(sb_update_dir) - - # re-launch SB - p = subprocess.Popen(sb_executable, cwd=os.getcwd()) - -except Exception, e: - log("Exception while updating: "+str(e)) - raise - -if log_file: - log_file.close()