def two(self, **kwargs): """ Accept server and show internal web server page """ # Save server details if kwargs: kwargs['enable'] = 1 sabnzbd.interface.handle_server(kwargs) # Create web server page info = self.info.copy() info['num'] = '» %s' % T('Step Two') info['number'] = 2 info['T'] = Ttemplate host = cfg.cherryhost() info['host'] = host # Allow special operation if host is not one of the defaults if host not in ('localhost', '0.0.0.0'): info['custom_host'] = True else: info['custom_host'] = False info['have_ssl'] = bool(sabnzbd.newswrapper.HAVE_SSL) info['enable_https'] = cfg.enable_https() info['autobrowser'] = cfg.autobrowser() info['web_user'] = cfg.username() info['web_pass'] = cfg.password() template = Template(file=os.path.join(self.__web_dir, 'two.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond()
def two(self, **kwargs): """ Accept server and show internal web server page """ # Save server details if kwargs: kwargs['enable'] = 1 sabnzbd.interface.handle_server(kwargs) # Create web server page info = self.info.copy() info['num'] = '» %s' % T('Step Two') info['number'] = 2 info['T'] = Ttemplate host = cfg.cherryhost() info['host'] = host # Allow special operation if host is not one of the defaults if host not in ('localhost','0.0.0.0'): info['custom_host'] = True else: info['custom_host'] = False info['have_ssl'] = bool(sabnzbd.newswrapper.HAVE_SSL) info['enable_https'] = cfg.enable_https() info['autobrowser'] = cfg.autobrowser() info['web_user'] = cfg.username() info['web_pass'] = cfg.password() template = Template(file=os.path.join(self.__web_dir, 'two.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond()
def launch_a_browser(url, force=False): """ Launch a browser pointing to the URL """ if not force and not cfg.autobrowser() or sabnzbd.DAEMON: return if '::1' in url and '[::1]' not in url: # Get around idiosyncrasy in Python runtime url = url.replace('::1', '[::1]') if cfg.enable_https() and not cfg.https_port.get_int(): # Must use https, because http is not available url = url.replace('http:', 'https:') if 'localhost' in url and not cfg.ipv6_hosting(): url = url.replace('localhost', '127.0.0.1') logging.info("Launching browser with %s", url) try: if url and not url.startswith('http'): url = 'file:///%s' % url if webbrowser: webbrowser.open(url, 2, 1) else: logging.info('Not showing panic message in webbrowser, no support found') except: logging.warning(T('Cannot launch the browser, probably not found')) logging.info("Traceback: ", exc_info=True)
def launch_a_browser(url, force=False): """ Launch a browser pointing to the URL """ if not force and not cfg.autobrowser() or sabnzbd.DAEMON: return if "::1" in url and "[::1]" not in url: # Get around idiosyncrasy in Python runtime url = url.replace("::1", "[::1]") if cfg.enable_https() and not cfg.https_port.get_int(): # Must use https, because http is not available url = url.replace("http:", "https:") if "localhost" in url and not cfg.ipv6_hosting(): url = url.replace("localhost", "127.0.0.1") logging.info("Launching browser with %s", url) try: if url and not url.startswith("http"): url = "file:///%s" % url if webbrowser: webbrowser.open(url, 2, 1) else: logging.info("Not showing panic message in webbrowser, no support found") except: logging.warning(T("Cannot launch the browser, probably not found")) logging.info("Traceback: ", exc_info=True)
def launch_a_browser(url, force=False): """ Launch a browser pointing to the URL """ if not force and not cfg.autobrowser() or sabnzbd.DAEMON: return if '::1' in url and '[::1]' not in url: # Get around idiosyncrasy in Python runtime url = url.replace('::1', '[::1]') if cfg.enable_https() and not cfg.https_port.get_int(): # Must use https, because http is not available url = url.replace('http:', 'https:') if 'localhost' in url and not cfg.ipv6_hosting(): url = url.replace('localhost', '127.0.0.1') logging.info("Launching browser with %s", url) try: if url and not url.startswith('http'): url = 'file:///%s' % url if webbrowser: webbrowser.open(url, 2, 1) else: logging.info( 'Not showing panic message in webbrowser, no support found') except: logging.warning(T('Cannot launch the browser, probably not found')) logging.info("Traceback: ", exc_info=True)
def panic_message(panic, a=None, b=None): """Create the panic message from templates """ if sabnzbd.WIN32: os_str = Ta("Press Startkey+R and type the line (example):") prog_path = '"%s"' % sabnzbd.MY_FULLNAME else: os_str = Ta("Open a Terminal window and type the line (example):") prog_path = sabnzbd.MY_FULLNAME if panic == PANIC_PORT: newport = int(b) + 1 newport = "%s" % newport msg = MSG_BAD_PORT() % (b, a, os_str, prog_path, a, newport) elif panic == PANIC_XPORT: if int(b) < 1023: newport = 1024 else: newport = int(b) + 1 newport = "%s" % newport msg = MSG_ILL_PORT() % (b, a, os_str, prog_path, a, newport) elif panic == PANIC_TEMPL: msg = MSG_BAD_TEMPL() % a elif panic == PANIC_QUEUE: msg = MSG_BAD_QUEUE() % (a, os_str, prog_path) elif panic == PANIC_FWALL: if a: msg = MSG_BAD_FWALL() % Ta("It is likely that you are using ZoneAlarm on Vista.<br>") else: msg = MSG_BAD_FWALL() % "<br>" elif panic == PANIC_SQLITE: msg = MSG_SQLITE() elif panic == PANIC_HOST: msg = MSG_BAD_HOST() % (os_str, prog_path, "localhost", b) else: msg = MSG_OTHER() % (a, b) msg = MSG_BAD_NEWS() % ( sabnzbd.MY_NAME, sabnzbd.__version__, sabnzbd.MY_NAME, sabnzbd.__version__, msg, Ta("Program did not start!"), ) if sabnzbd.WIN_SERVICE: sabnzbd.WIN_SERVICE.ErrLogger("Panic exit", msg) if (not cfg.autobrowser()) or sabnzbd.DAEMON: return msgfile, url = tempfile.mkstemp(suffix=".html") os.write(msgfile, msg) os.close(msgfile) return url
def panic_message(panic, a=None, b=None): """Create the panic message from templates """ if sabnzbd.WIN32: os_str = Ta('Press Startkey+R and type the line (example):') prog_path = '"%s"' % sabnzbd.MY_FULLNAME else: os_str = Ta('Open a Terminal window and type the line (example):') prog_path = sabnzbd.MY_FULLNAME if panic == PANIC_PORT: newport = int(b) + 1 newport = "%s" % newport msg = MSG_BAD_PORT() % (b, a, os_str, prog_path, a, newport) elif panic == PANIC_XPORT: if int(b) < 1023: newport = 1024 else: newport = int(b) + 1 newport = "%s" % newport msg = MSG_ILL_PORT() % (b, a, os_str, prog_path, a, newport) elif panic == PANIC_TEMPL: msg = MSG_BAD_TEMPL() % a elif panic == PANIC_QUEUE: msg = MSG_BAD_QUEUE() % (a, os_str, prog_path) elif panic == PANIC_FWALL: if a: msg = MSG_BAD_FWALL() % Ta( 'It is likely that you are using ZoneAlarm on Vista.<br>') else: msg = MSG_BAD_FWALL() % "<br>" elif panic == PANIC_SQLITE: msg = MSG_SQLITE() elif panic == PANIC_HOST: msg = MSG_BAD_HOST() % (os_str, prog_path, 'localhost', b) else: msg = MSG_OTHER() % (a, b) msg = MSG_BAD_NEWS() % (sabnzbd.MY_NAME, sabnzbd.__version__, sabnzbd.MY_NAME, sabnzbd.__version__, msg, Ta('Program did not start!')) if sabnzbd.WIN_SERVICE: sabnzbd.WIN_SERVICE.ErrLogger('Panic exit', msg) if (not cfg.autobrowser()) or sabnzbd.DAEMON: return msgfile, url = tempfile.mkstemp(suffix='.html') os.write(msgfile, msg) os.close(msgfile) return url
def launch_a_browser(url, force=False): """Launch a browser pointing to the URL """ if not force and not cfg.autobrowser() or sabnzbd.DAEMON: return if cfg.enable_https() and not cfg.https_port.get_int(): # Must use https, because http is not available url = url.replace('http:', 'https:') logging.info("Lauching browser with %s", url) try: webbrowser.open(url, 2, 1) except: logging.warning(Ta('Cannot launch the browser, probably not found')) logging.info("Traceback: ", exc_info = True)
def panic_message(panic_code, a=None, b=None): """ Create the panic message from templates """ if sabnzbd.WIN32: os_str = T("Press Startkey+R and type the line (example):") prog_path = '"%s"' % sabnzbd.MY_FULLNAME else: os_str = T("Open a Terminal window and type the line (example):") prog_path = sabnzbd.MY_FULLNAME if panic_code == PANIC_PORT: newport = int(b) + 1 newport = "%s" % newport msg = MSG_BAD_PORT() % (b, a, os_str, prog_path, a, newport) elif panic_code == PANIC_TEMPL: msg = MSG_BAD_TEMPL() % a elif panic_code == PANIC_QUEUE: msg = MSG_BAD_QUEUE() % (a, os_str, prog_path) elif panic_code == PANIC_SQLITE: msg = MSG_SQLITE() elif panic_code == PANIC_HOST: msg = MSG_BAD_HOST() % (os_str, prog_path, "localhost", b) else: msg = MSG_OTHER() % (a, b) msg = MSG_BAD_NEWS() % ( sabnzbd.MY_NAME, sabnzbd.__version__, sabnzbd.MY_NAME, sabnzbd.__version__, msg, T("Program did not start!"), ) if sabnzbd.WIN_SERVICE: sabnzbd.WIN_SERVICE.ErrLogger("Panic exit", msg) if (not cfg.autobrowser()) or sabnzbd.DAEMON: return msgfile, url = tempfile.mkstemp(suffix=".html") os.write(msgfile, utob(msg)) os.close(msgfile) return url
def launch_a_browser(url, force=False): """Launch a browser pointing to the URL """ if not force and not cfg.autobrowser() or sabnzbd.DAEMON: return if "::1" in url and not "[::1]" in url: # Get around ideosyncrasy in Python runtime url = url.replace("::1", "[::1]") if cfg.enable_https() and not cfg.https_port.get_int(): # Must use https, because http is not available url = url.replace("http:", "https:") logging.info("Lauching browser with %s", url) try: if url and not url.startswith("http"): url = "file:///%s" % url webbrowser.open(url, 2, 1) except: logging.warning(Ta("Cannot launch the browser, probably not found")) logging.info("Traceback: ", exc_info=True)
def panic_message(panic, a=None, b=None): """ Create the panic message from templates """ if sabnzbd.WIN32: os_str = T('Press Startkey+R and type the line (example):') prog_path = '"%s"' % sabnzbd.MY_FULLNAME else: os_str = T('Open a Terminal window and type the line (example):') prog_path = sabnzbd.MY_FULLNAME if panic == PANIC_PORT: newport = int(b) + 1 newport = "%s" % newport msg = MSG_BAD_PORT() % (b, a, os_str, prog_path, a, newport) elif panic == PANIC_TEMPL: msg = MSG_BAD_TEMPL() % a elif panic == PANIC_QUEUE: msg = MSG_BAD_QUEUE() % (a, os_str, prog_path) elif panic == PANIC_SQLITE: msg = MSG_SQLITE() elif panic == PANIC_HOST: msg = MSG_BAD_HOST() % (os_str, prog_path, 'localhost', b) else: msg = MSG_OTHER() % (a, b) msg = MSG_BAD_NEWS() % (sabnzbd.MY_NAME, sabnzbd.__version__, sabnzbd.MY_NAME, sabnzbd.__version__, msg, T('Program did not start!')) if sabnzbd.WIN_SERVICE: sabnzbd.WIN_SERVICE.ErrLogger('Panic exit', msg) if (not cfg.autobrowser()) or sabnzbd.DAEMON: return msgfile, url = tempfile.mkstemp(suffix='.html') os.write(msgfile, msg) os.close(msgfile) return url