diff --git a/SABnzbd.py b/SABnzbd.py index d4c5c1f..df2f9b5 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -613,11 +613,9 @@ def get_webhost(cherryhost, cherryport, https_port): def is_sabnzbd_running(url): """ Return True when there's already a SABnzbd instance running. """ - import urllib2 try: url = '%s&mode=version' % (url) - s = urllib2.urlopen(url) - ver = s.read() + ver = sabnzbd.newsunpack.get_from_url(url) if ver and ver.strip(' \n\r\t') == sabnzbd.__version__: return True else: @@ -1011,6 +1009,9 @@ def main(): except: Bail_Out(browserhost, cherryport, '49') + # Find external programs + sabnzbd.newsunpack.find_programs(sabnzbd.DIR_PROG) + # Windows instance is reachable through registry url = None if sabnzbd.WIN32: @@ -1186,9 +1187,6 @@ def main(): else: autobrowser = sabnzbd.cfg.autobrowser() - # Find external programs - sabnzbd.newsunpack.find_programs(sabnzbd.DIR_PROG) - if not sabnzbd.WIN_SERVICE and not getattr(sys, 'frozen', None) == 'macosx_app': signal.signal(signal.SIGINT, sabnzbd.sig_handler) signal.signal(signal.SIGTERM, sabnzbd.sig_handler) @@ -1296,7 +1294,7 @@ def main(): 'request.show_tracebacks': True, 'checker.check_localhost' : bool(consoleLogging), 'error_page.401': sabnzbd.misc.error_page_401 - }) + }) static = {'tools.staticdir.on': True, 'tools.staticdir.dir': os.path.join(web_dir, 'static')} @@ -1399,7 +1397,7 @@ def main(): while not sabnzbd.SABSTOP: if sabnzbd.WIN_SERVICE: rc = win32event.WaitForMultipleObjects((sabnzbd.WIN_SERVICE.hWaitStop, - sabnzbd.WIN_SERVICE.overlapped.hEvent), 0, 3000) + sabnzbd.WIN_SERVICE.overlapped.hEvent), 0, 3000) if rc == win32event.WAIT_OBJECT_0: if mail: mail.send('stop') @@ -1510,9 +1508,9 @@ if sabnzbd.WIN32: _svc_display_name_ = 'SABnzbd Binary Newsreader' _svc_deps_ = ["EventLog", "Tcpip", "SABHelper"] _svc_description_ = 'Automated downloading from Usenet. ' \ - 'Set to "automatic" to start the service at system startup. ' \ - 'You may need to login with a real user account when you need ' \ - 'access to network shares.' + 'Set to "automatic" to start the service at system startup. ' \ + 'You may need to login with a real user account when you need ' \ + 'access to network shares.' def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) @@ -1650,4 +1648,3 @@ if __name__ == '__main__': else: main() - diff --git a/licenses/Python/LICENSE-curl.txt b/licenses/Python/LICENSE-curl.txt new file mode 100644 index 0000000..3c97b41 --- /dev/null +++ b/licenses/Python/LICENSE-curl.txt @@ -0,0 +1,77 @@ +The CURL binaries have been downloaded from: +http://www.paehl.com/open_source/?CURL_7.21.6 + +License info: + +================================================================================= +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1996 - 2011, Daniel Stenberg, . + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. +================================================================================= + _ _ ____ _ + ___| | | | _ \| | + / __| | | | |_) | | + | (__| |_| | _ <| |___ + \___|\___/|_| \_\_____| + +README + + Curl is a command line tool for transferring data specified with URL + syntax. Find out how to use curl by reading the curl.1 man page or the + MANUAL document. Find out how to install Curl by reading the INSTALL + document. + + libcurl is the library curl is using to do its job. It is readily + available to be used by your software. Read the libcurl.3 man page to + learn how! + + You find answers to the most frequent questions we get in the FAQ document. + + Study the COPYING file for distribution terms and similar. If you distribute + curl binaries or other binaries that involve libcurl, you might enjoy the + LICENSE-MIXING document. + +CONTACT + + If you have problems, questions, ideas or suggestions, please contact us + by posting to a suitable mailing list. See http://curl.haxx.se/mail/ + + All contributors to the project are listed in the THANKS document. + +WEB SITE + + Visit the curl web site for the latest news and downloads: + + http://curl.haxx.se/ + +GIT + + To download the very latest source off the GIT server do this: + + git clone git://github.com/bagder/curl.git + + (you'll get a directory named curl created, filled with the source code) + +NOTICE + + Curl contains pieces of source code that is Copyright (c) 1998, 1999 + Kungliga Tekniska Högskolan. This notice is included here to comply with the + distribution terms. diff --git a/package.py b/package.py index 82bae25..3202449 100755 --- a/package.py +++ b/package.py @@ -523,6 +523,10 @@ elif target in ('binary', 'installer'): setup(**options) rename_file('dist', Win32HelperName, Win32ServiceHelpName) + ############################ + # Copy curl files + shutil.copy2(r'win\curl\curl.exe', r'dist\lib') + shutil.copy2(r'win\curl\libssh2.dll', r'dist\lib') ############################ if target == 'installer': diff --git a/sabnzbd/newsunpack.py b/sabnzbd/newsunpack.py index d1bef34..928199f 100644 --- a/sabnzbd/newsunpack.py +++ b/sabnzbd/newsunpack.py @@ -69,6 +69,8 @@ NICE_COMMAND = None ZIP_COMMAND = None IONICE_COMMAND = None RAR_PROBLEM = False +CURL_COMMAND = None + def find_programs(curdir): """Find external programs @@ -103,6 +105,7 @@ def find_programs(curdir): sabnzbd.newsunpack.RAR_COMMAND = check(curdir, 'win/unrar/UnRAR.exe') sabnzbd.newsunpack.PAR2C_COMMAND = check(curdir, 'win/par2/par2-classic.exe') sabnzbd.newsunpack.ZIP_COMMAND = check(curdir, 'win/unzip/unzip.exe') + sabnzbd.newsunpack.CURL_COMMAND = check(curdir, 'lib/curl.exe') else: if not sabnzbd.newsunpack.PAR2_COMMAND: sabnzbd.newsunpack.PAR2_COMMAND = find_on_path('par2') @@ -1403,3 +1406,23 @@ def list2cmdline(lst): else: nlst.append(arg) return ' '.join(nlst) + + +#------------------------------------------------------------------------------ +# Work-around for the failure of Python2.5 on Windows to support IPV6 with HTTPS + +def get_from_url(url): + if sabnzbd.WIN32 and ' 2.5.' in sys.version and sabnzbd.newsunpack.CURL_COMMAND: + command = [sabnzbd.newsunpack.CURL_COMMAND, "-k", url] + stup, need_shell, command, creationflags = build_command(command) + p = subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + startupinfo=stup, creationflags=creationflags) + + output = p.stdout.read() + p.wait() + else: + import urllib2 + s = urllib2.urlopen(url) + output = s.read() + return output diff --git a/sabnzbd/utils/upload.py b/sabnzbd/utils/upload.py index 1856b4f..5339ce1 100644 --- a/sabnzbd/utils/upload.py +++ b/sabnzbd/utils/upload.py @@ -25,6 +25,7 @@ import logging import os import sabnzbd.cfg as cfg from sabnzbd.misc import get_ext, get_filename +import sabnzbd.newsunpack from sabnzbd.dirscanner import ProcessArchiveFile, ProcessSingleFile @@ -43,7 +44,7 @@ def upload_file(url, fp): password = cfg.password() if username and password: url = '%s&ma_username=%s&ma_password=%s' % (url, username, password) - urllib2.urlopen(url) + sabnzbd.newsunpack.get_from_url(url) except: logging.error("Failed to upload file: %s", fp) logging.info("Traceback: ", exc_info = True) diff --git a/win/curl/curl.exe b/win/curl/curl.exe new file mode 100644 index 0000000..8aeeaea Binary files /dev/null and b/win/curl/curl.exe differ diff --git a/win/curl/libssh2.dll b/win/curl/libssh2.dll new file mode 100644 index 0000000..e0e4223 Binary files /dev/null and b/win/curl/libssh2.dll differ