def main(parsed_args, skip_depl_conf=False): status = None if parsed_args.deploy: depl_args = { "docker_compose_path": settings.get("compose_path"), "domain": parsed_args.domain, "email": parsed_args.email, "cert_type": "letsencrypt" if parsed_args.letsencrypt else "custom", "stack_name": settings.get("name") if parsed_args.stack_name is None else parsed_args.stack_name, "addr": parsed_args.addr, "http_proxy": parsed_args.http_proxy, "https_proxy": parsed_args.https_proxy, "no_port_binding": parsed_args.no_port_binding, "dev": parsed_args.dev, "no_prompt": parsed_args.test, "central": parsed_args.central } deploy.prepare(skip_depl_config=skip_depl_conf, is_update=False, **depl_args) elif parsed_args.list: manage.list_(parsed_args.list) elif parsed_args.remove: manage.remove(parsed_args.remove) elif parsed_args.logs: manage.logs(parsed_args.logs) elif parsed_args.update: manage.update() else: if parsed_args.start: status = manage.start() elif parsed_args.stop: status = manage.stop() elif parsed_args.restart: status = manage.restart() if status == 1: log.info( "No Coral services were found (Coral stack is not currently deployed)" )
def remove_coral_objects(obj_type: str, silent: bool = False, list_found_objs: bool = True, prompt: bool = True, is_dep: bool = False): if not silent: log.info( f"Removing{' dependent ' if is_dep else ' '}Coral {obj_type}s...") cleanup_params = settings.get("cleanup_params")[obj_type] rm_confirmation_msg, all_, quiet, format_, filters, force = [ value for value in cleanup_params.values() ] obj_list = get_coral_objs(obj_type, all_=all_, quiet=quiet, format_=f"\"{format_}\"", filters=filters) if obj_list: bullets_obj_list = "\n".join( [f"- {line}" for line in obj_list.split("\n")]) if list_found_objs and not silent: log.info( f"The following Coral {obj_type}s were found:\n{bullets_obj_list}" ) log_stdout.info("") if prompt: question = f"{rm_confirmation_msg}\nAre you sure you want to remove these {obj_type}s? (y/n) " answer = fish.valid_answer_from_prompt( question, valid_answers=settings.get("prompt_boolean_answers")) log_file.info(question.replace("\n", " ") + answer) if not prompt or fish.user_prompt_yes(answer): remove_coral_obj_dependencies(obj_type, silent=silent) obj_ids = [ i for i, j in (obj.split("\t") for obj in obj_list.split("\n")) ] if not silent: log.info(f"Removing {obj_type}s...") res = swarmadmin.rm(obj_type, obj_ids, force=force, suppress_stdout=silent) fish.handle(res) if not silent: log.info(f"Done!") else: if not silent: log.info(f"No Coral {obj_type}s were found. Skipping...")
def track_progress(stack_name, docker_compose_path): curr_depl_conf = get_curr_depl_config() apps = curr_depl_conf["basic"]["apps"] timeouts = settings.get("progress_tracking_timeout") addrs = {} for app in apps: service_name = f"{stack_name}_{app}" timeout = timeouts[app] curr_replicas = 0 while curr_replicas < 1: res = fish.handle(swarmadmin.get_service_replicas(service_name)) curr_replicas = int(res["stdout"]) time.sleep(0.1) task_id = swarmadmin.get_task_id_from_service(service_name) container_id = swarmadmin.get_container_id_from_task(task_id) addr = "" while addr == "": try: addr = swarmadmin.get_container_addr_in_network( container_id, "docker_gwbridge") time.sleep(0.1) except: pass addrs[app] = addr return addrs
def check_secrets(docker_compose_path: str, no_prompt: bool = False): log.info("Checking Coral secrets...") required_secrets = swarmadmin.get_objs_from_compose( "secret", docker_compose_path) missing_secrets = list( filter(lambda x: not swarmadmin.obj_exists("secret", x), required_secrets)) if len(missing_secrets) > 0: log.info("Some required secrets are missing") if no_prompt: raise Exception( "When running in test mode, all secrets must be manually created beforehand." ) else: prompt_secrets(missing_secrets) else: if not no_prompt: question = "All required secrets are defined. Do you wish to redefine them? (y/n) " answer = fish.valid_answer_from_prompt( question, valid_answers=settings.get("prompt_boolean_answers")) log_file.info(question + answer) if fish.user_prompt_yes(answer): manage.remove_coral_objects("secret", silent=True, list_found_objs=False, prompt=False) prompt_secrets(required_secrets)
def config_depl_params(domain: str, email: str, cert_type: str, stack_name: str, advertise_addr: str = None, http_proxy: str = None, https_proxy: str = None, no_port_binding: bool = False, dev: bool = False, central: bool = False): log.info("Configuring deployment parameters...") depl_conf_path = settings.get_conf_file_path("deployment") depl_conf_template = settings.get("deployment_template") # set basic configurations basic_depl_conf = depl_conf_template["basic"] basic_depl_conf["domain"] = domain basic_depl_conf["email"] = email basic_depl_conf["cert_type"] = cert_type basic_depl_conf["stack_name"] = stack_name # set advanced configurations adv_depl_conf = depl_conf_template["advanced"] adv_depl_conf["advertise_addr"] = advertise_addr adv_depl_conf["http_proxy"] = http_proxy adv_depl_conf["https_proxy"] = https_proxy adv_depl_conf["no_port_binding"] = no_port_binding adv_depl_conf["dev_images"] = dev adv_depl_conf["central"] = central depl_conf = {"basic": basic_depl_conf, "advanced": adv_depl_conf} fish.write_json(depl_conf, depl_conf_path, indent=2)
def update(): question = "Coral will be stopped in order to perform the update. Do you wish to continue? (y/n) " answer = fish.valid_answer_from_prompt( question, valid_answers=settings.get("prompt_boolean_answers")) log_file.info(question + answer) if fish.user_prompt_yes(answer): docker_compose_path = settings.get("compose_path") original_compose_file = None log.info("Updating Coral Docker images...") # check if a current deployment is using dev images curr_depl_conf = deploy.get_curr_depl_config() if curr_depl_conf is not None: original_compose_file = fish.read_file(docker_compose_path) dev = curr_depl_conf["advanced"]["dev_images"] if dev: deploy.switch_to_dev_images( docker_compose_path) # switch to dev images try: registry_login() pull_coral_images(docker_compose_path) finally: if original_compose_file is not None: fish.write_file(original_compose_file, docker_compose_path) log_stdout.info("") log.info("Coral Docker images successfully updated!") curr_depl_conf = deploy.get_curr_depl_config() if (curr_depl_conf is None): log.info("Cannot start Coral. Please deploy first.") else: domain = curr_depl_conf["basic"][ "domain"] # needed for logs after deployment deploy.prepare(skip_depl_config=True, is_update=True, docker_compose_path=docker_compose_path, domain=domain, email=None, cert_type=None, stack_name=None, no_prompt=True)
def registry_login(): resgistry = settings.get('docker_registry') log.info(f"Credentials for {resgistry}:") while True: try: swarmadmin.login(resgistry) break except Exception as e: log_file.warning("{0}: {1}".format(type(e).__name__, e))
def index(): setting = settings.get('what_credentials') if setting[1] == None or setting[1] == '': return render_template( 'settings.html', settings=settings.get_all(), message="Please set your whatcd username and password.", message_class="alert-error") torrents = torrent.get_recent() return render_template('index.html', torrents=torrents, userinfo=database.userinfo())
def check_skip_depl_config(no_prompt: bool = False): curr_depl_conf = get_curr_depl_config() if curr_depl_conf is None: return False curr_depl_conf = json.dumps(curr_depl_conf, indent=2) log.info( "Previous deployment configuration found:\n{0}".format(curr_depl_conf)) if no_prompt: return True else: question = f"Do you wish to reuse the configuration above? (y/n) " answer = fish.valid_answer_from_prompt( question, valid_answers=settings.get("prompt_boolean_answers")) log_file.info(question + answer) return fish.user_prompt_yes(answer)
def prompt_secrets(secrets: list): log_stdout.info("Please provide the secrets below:") for secret_name in secrets: secret_content = getpass.getpass(prompt=f" {secret_name}: ") min_secret_len = settings.get("min_secret_len") while len(secret_content) < min_secret_len: log.info( f"Secrets must use at least {min_secret_len} characters. Try again:" ) secret_content = getpass.getpass(prompt=f" {secret_name}: ") swarmadmin.create_secret(secret_content, secret_name, "system=Coral") log_stdout.warn( "\n\033[1;31mIf you forget your passwords, you will loose access to your data.\nIt is highly recommended that you also manually store the passwords somewhere else safe.\033[0m" ) input("Press Enter to continue...")
def scale_all_services(n_replicas: int, quiet: bool = False): coral_services = get_coral_objs("service", quiet=True, format_="{{.Name}}") if coral_services: coral_services_list = coral_services.split('\n') n_services = len(coral_services_list) # scale services one by one so progress can be displayed in stdout for i, service in enumerate(coral_services_list): # skip if service is already stopped/started res = swarmadmin.get_service_replicas(service) fish.handle(res) curr_replicas = int(res["stdout"]) if n_replicas == 0 and curr_replicas == 0 or n_replicas == 1 and curr_replicas == 1: state = "stopped" if n_replicas == 0 else "running" if not quiet: log.info(f"{service} is already {state}. Skipping...") fish.print_progress_bar(i + 1, n_services, prefix=f"Progress:", suffix="Complete\n", length=50) continue # TODO: check if service image needs to be pulled and warn user res = swarmadmin.scale([service], n_replicas, suppress_stdout=quiet, suppress_stderr=quiet, timeout=settings.get("scaling_timeout")) if not quiet: fish.print_progress_bar(i + 1, n_services, prefix=f"Progress:", suffix="Complete\n", length=50) fish.handle(res) if not quiet: log_stdout.info("") return 0 else: return 1
def check_central_mon(env_file_path: str, no_prompt: bool = False): log.info("Checking for central monitoring configuration...") central_mon_url = get_central_monitor_url() if (len(central_mon_url["value"]) == 0): log.warn( f"A central monitoring URL has not been defined in {env_file_path}, line {str(central_mon_url['index'] + 1)}.\nThe monitoring features described in the 'Coral Monitor Stack' section of README.md will be disabled." ) if not no_prompt: question = "Do you wish to continue? (y/n) " answer = fish.valid_answer_from_prompt( question, valid_answers=settings.get("prompt_boolean_answers")) log_file.info(question + answer) if fish.user_prompt_no(answer): sys.exit(0) return False else: log.info(f"Using {central_mon_url['value']} for central monitoring...") return True
def arttype_list(): setting = get() available_arttypes = [{'media_type': 'movie', 'bulk_enabled': setting.get('movie_poster'), 'solo_enabled': 'true', 'gui_string': 32128, 'art_type': 'poster', 'filename': 'poster.jpg'}, {'media_type': 'movie', 'bulk_enabled': setting.get('movie_fanart'), 'solo_enabled': 'true', 'gui_string': 32121, 'art_type': 'fanart', 'filename': 'fanart.jpg'}, {'media_type': 'movie', 'bulk_enabled': setting.get('movie_extrafanart'), 'solo_enabled': 'false', 'gui_string': 32122, 'art_type': 'extrafanart', 'filename': ''}, {'media_type': 'movie', 'bulk_enabled': setting.get('movie_extrathumbs'), 'solo_enabled': 'false', 'gui_string': 32131, 'art_type': 'extrathumbs', 'filename': 'thumb%s.jpg'}, {'media_type': 'movie', 'bulk_enabled': setting.get('movie_logo'), 'solo_enabled': 'true', 'gui_string': 32126, 'art_type': 'clearlogo', 'filename': 'logo.png'}, {'media_type': 'movie', 'bulk_enabled': setting.get('movie_clearart'), 'solo_enabled': 'true', 'gui_string': 32125, 'art_type': 'clearart', 'filename': 'clearart.png'}, {'media_type': 'movie', 'bulk_enabled': setting.get('movie_discart'), 'solo_enabled': 'true', 'gui_string': 32132, 'art_type': 'discart', 'filename': 'disc.png'}, {'media_type': 'movie', 'bulk_enabled': setting.get('movie_landscape'), 'solo_enabled': 'true', 'gui_string': 32130, 'art_type': 'landscape', 'filename': 'landscape.jpg'}, {'media_type': 'movie', 'bulk_enabled': setting.get('movie_banner'), 'solo_enabled': 'true', 'gui_string': 32123, 'art_type': 'banner', 'filename': 'banner.jpg'}, # append tv show list {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_poster'), 'solo_enabled': 'true', 'gui_string': 32128, 'art_type': 'poster', 'filename': 'poster.jpg'}, {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_seasonposter'), 'solo_enabled': 'true', 'gui_string': 32129, 'art_type': 'seasonposter', 'filename': 'season%02d-poster.jpg'}, {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_fanart'), 'solo_enabled': 'true', 'gui_string': 32121, 'art_type': 'fanart', 'filename': 'fanart.jpg'}, {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_extrafanart'), 'solo_enabled': 'false', 'gui_string': 32122, 'art_type': 'extrafanart', 'filename': ''}, {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_clearart'), 'solo_enabled': 'true', 'gui_string': 32125, 'art_type': 'clearart', 'filename': 'clearart.png'}, {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_logo'), 'solo_enabled': 'true', 'gui_string': 32126, 'art_type': 'clearlogo', 'filename': 'logo.png'}, {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_landscape'), 'solo_enabled': 'true', 'gui_string': 32130, 'art_type': 'landscape', 'filename': 'landscape.jpg'}, {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_seasonlandscape'), 'solo_enabled': 'true', 'gui_string': 32134, 'art_type': 'seasonlandscape', 'filename': 'season%02d-landscape.jpg'}, {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_showbanner'), 'solo_enabled': 'true', 'gui_string': 32123, 'art_type': 'banner', 'filename': 'banner.jpg'}, {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_seasonbanner'), 'solo_enabled': 'true', 'gui_string': 32124, 'art_type': 'seasonbanner', 'filename': 'season%02d-banner.jpg'}, {'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_characterart'), 'solo_enabled': 'true', 'gui_string': 32127, 'art_type': 'characterart', 'filename': 'character.png'}, # Musicvideo {'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_poster'), 'solo_enabled': 'true', 'gui_string': 32128, 'art_type': 'poster', 'filename': 'poster.jpg'}, {'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_fanart'), 'solo_enabled': 'true', 'gui_string': 32121, 'art_type': 'fanart', 'filename': 'fanart.jpg'}, {'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_extrafanart'), 'solo_enabled': 'false', 'gui_string': 32122, 'art_type': 'extrafanart', 'filename': ''}, {'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_extrathumbs'), 'solo_enabled': 'false', 'gui_string': 32131, 'art_type': 'extrathumbs', 'filename': 'thumb%s.jpg'}, {'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_logo'), 'solo_enabled': 'true', 'gui_string': 32126, 'art_type': 'clearlogo', 'filename': 'logo.png'}, {'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_clearart'), 'solo_enabled': 'true', 'gui_string': 32125, 'art_type': 'clearart', 'filename': 'clearart.png'}, {'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_discart'), 'solo_enabled': 'true', 'gui_string': 32132, 'art_type': 'cdart', 'filename': 'disc.png'}] return available_arttypes
from lib.utils import * from traceback import print_exc from urlparse import urlsplit from xml.parsers.expat import ExpatError arttype_list = arttype_list() cancelled = False download_arttypes = [] download_counter = {'Total Artwork': 0} download_list = [] download_succes = False failed_items = [] image_list = [] limit = get_limit() reportdata = '[B]Artwork Downloader:[/B]' setting = get() startup = {'mediatype': False, 'dbid': False, 'mode': False, 'silent': False} class Main: def __init__(self): if not check(): # Check if there are some faulty combinations present sys.exit(1) if self.initialise(): global setting global startup providers = provider.get_providers() # Check for silent background mode if startup['silent']: setting['background'] = True setting['notify'] = False
from lib.script_exceptions import * from lib.settings import get_limit, get, check from lib.utils import * from xml.parsers.expat import ExpatError arttype_list = arttype_list() cancelled = False download_arttypes = [] download_counter = {'Total Artwork': 0} download_list = [] download_succes = False failed_items = [] image_list = [] limit = get_limit() reportdata = '[B]Artwork Downloader:[/B]' setting = get() setting_limit = get_limit() startup = {'mediatype': False, 'dbid': False, 'mode': False, 'silent': False} class Main: def __init__(self): if not check(): # Check if there are some faulty combinations present sys.exit(1) if self.initialise(): global setting global startup providers = provider.get_providers() # Check for silent background mode
# -*- coding: utf-8 -*- import time from lib import settings settings.init() from lib import wsn from lib import light from lib import logger settings = settings.settings logger.SETTINGS = settings log = logger.init_log("main", settings) dt = 1 / float(settings.get("dmx", "fps")) if __name__ == "__main__": try: xbee = wsn.Xbee() dmx_th = light.DmxThread() sensor_th = wsn.SensorThread(xbee, dmx_th.dmxout) dmx_th.set_compute_all(sensor_th.sensors.compute_all) #sensors = wsn.SensorManager(tuple(settings.get("sensor", "addr")), dmx.dmxout) if xbee.init(): sensor_th.start() dmx_th.start() while True: time.sleep(0.05) else: log.error("Can't init Xbee")
def check_auth(username, password): creds = settings.get('webui_credentials') return username == creds[1] and password == creds[2]
def needs_auth(): creds = settings.get('webui_credentials') return creds[1] == None or creds[1] == ''
def artype_list(): setting = get() available_arttypes = [ { 'media_type': 'movie', 'bulk_enabled': setting.get('movie_poster'), 'solo_enabled': 'true', 'gui_string': 32128, 'art_type': 'poster', 'filename': 'poster.jpg' }, { 'media_type': 'movie', 'bulk_enabled': setting.get('movie_fanart'), 'solo_enabled': 'true', 'gui_string': 32121, 'art_type': 'fanart', 'filename': 'fanart.jpg' }, { 'media_type': 'movie', 'bulk_enabled': setting.get('movie_extrafanart'), 'solo_enabled': 'false', 'gui_string': 32122, 'art_type': 'extrafanart', 'filename': '' }, { 'media_type': 'movie', 'bulk_enabled': setting.get('movie_extrathumbs'), 'solo_enabled': 'false', 'gui_string': 32131, 'art_type': 'extrathumbs', 'filename': 'thumb%s.jpg' }, { 'media_type': 'movie', 'bulk_enabled': setting.get('movie_logo'), 'solo_enabled': 'true', 'gui_string': 32126, 'art_type': 'clearlogo', 'filename': 'logo.png' }, { 'media_type': 'movie', 'bulk_enabled': setting.get('movie_clearart'), 'solo_enabled': 'true', 'gui_string': 32125, 'art_type': 'clearart', 'filename': 'clearart.png' }, { 'media_type': 'movie', 'bulk_enabled': setting.get('movie_discart'), 'solo_enabled': 'true', 'gui_string': 32132, 'art_type': 'discart', 'filename': 'disc.png' }, { 'media_type': 'movie', 'bulk_enabled': setting.get('movie_landscape'), 'solo_enabled': 'true', 'gui_string': 32130, 'art_type': 'landscape', 'filename': 'landscape.jpg' }, { 'media_type': 'movie', 'bulk_enabled': setting.get('movie_banner'), 'solo_enabled': 'true', 'gui_string': 32123, 'art_type': 'banner', 'filename': 'banner.jpg' }, # append tv show list { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_poster'), 'solo_enabled': 'true', 'gui_string': 32128, 'art_type': 'poster', 'filename': 'poster.jpg' }, { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_seasonposter'), 'solo_enabled': 'true', 'gui_string': 32129, 'art_type': 'seasonposter', 'filename': 'season%02d-poster.jpg' }, { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_fanart'), 'solo_enabled': 'true', 'gui_string': 32121, 'art_type': 'fanart', 'filename': 'fanart.jpg' }, { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_extrafanart'), 'solo_enabled': 'false', 'gui_string': 32122, 'art_type': 'extrafanart', 'filename': '' }, { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_clearart'), 'solo_enabled': 'true', 'gui_string': 32125, 'art_type': 'clearart', 'filename': 'clearart.png' }, { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_logo'), 'solo_enabled': 'true', 'gui_string': 32126, 'art_type': 'clearlogo', 'filename': 'logo.png' }, { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_landscape'), 'solo_enabled': 'true', 'gui_string': 32130, 'art_type': 'landscape', 'filename': 'landscape.jpg' }, { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_seasonlandscape'), 'solo_enabled': 'true', 'gui_string': 32134, 'art_type': 'seasonlandscape', 'filename': 'season%02d-landscape.jpg' }, { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_showbanner'), 'solo_enabled': 'true', 'gui_string': 32123, 'art_type': 'banner', 'filename': 'banner.jpg' }, { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_seasonbanner'), 'solo_enabled': 'true', 'gui_string': 32124, 'art_type': 'seasonbanner', 'filename': 'season%02d-banner.jpg' }, { 'media_type': 'tvshow', 'bulk_enabled': setting.get('tvshow_characterart'), 'solo_enabled': 'true', 'gui_string': 32127, 'art_type': 'characterart', 'filename': 'character.png' }, # Musicvideo { 'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_poster'), 'solo_enabled': 'true', 'gui_string': 32128, 'art_type': 'poster', 'filename': 'poster.jpg' }, { 'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_fanart'), 'solo_enabled': 'true', 'gui_string': 32121, 'art_type': 'fanart', 'filename': 'fanart.jpg' }, { 'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_extrafanart'), 'solo_enabled': 'false', 'gui_string': 32122, 'art_type': 'extrafanart', 'filename': '' }, { 'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_extrathumbs'), 'solo_enabled': 'false', 'gui_string': 32131, 'art_type': 'extrathumbs', 'filename': 'thumb%s.jpg' }, { 'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_logo'), 'solo_enabled': 'true', 'gui_string': 32126, 'art_type': 'clearlogo', 'filename': 'logo.png' }, { 'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_clearart'), 'solo_enabled': 'true', 'gui_string': 32125, 'art_type': 'clearart', 'filename': 'clearart.png' }, { 'media_type': 'musicvideo', 'bulk_enabled': setting.get('musicvideo_discart'), 'solo_enabled': 'true', 'gui_string': 32132, 'art_type': 'cdart', 'filename': 'disc.png' } ] return available_arttypes
def arttype_list(): setting = get() available_arttypes = [ { "media_type": "movie", "bulk_enabled": setting.get("movie_poster"), "solo_enabled": "true", "gui_string": 32128, "art_type": "poster", "filename": "poster.jpg", }, { "media_type": "movie", "bulk_enabled": setting.get("movie_fanart"), "solo_enabled": "true", "gui_string": 32121, "art_type": "fanart", "filename": "fanart.jpg", }, { "media_type": "movie", "bulk_enabled": setting.get("movie_extrafanart"), "solo_enabled": "false", "gui_string": 32122, "art_type": "extrafanart", "filename": "", }, { "media_type": "movie", "bulk_enabled": setting.get("movie_extrathumbs"), "solo_enabled": "false", "gui_string": 32131, "art_type": "extrathumbs", "filename": "thumb%s.jpg", }, { "media_type": "movie", "bulk_enabled": setting.get("movie_logo"), "solo_enabled": "true", "gui_string": 32126, "art_type": "clearlogo", "filename": "logo.png", }, { "media_type": "movie", "bulk_enabled": setting.get("movie_clearart"), "solo_enabled": "true", "gui_string": 32125, "art_type": "clearart", "filename": "clearart.png", }, { "media_type": "movie", "bulk_enabled": setting.get("movie_discart"), "solo_enabled": "true", "gui_string": 32132, "art_type": "discart", "filename": "disc.png", }, { "media_type": "movie", "bulk_enabled": setting.get("movie_landscape"), "solo_enabled": "true", "gui_string": 32130, "art_type": "landscape", "filename": "landscape.jpg", }, { "media_type": "movie", "bulk_enabled": setting.get("movie_banner"), "solo_enabled": "true", "gui_string": 32123, "art_type": "banner", "filename": "banner.jpg", }, # append tv show list { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_poster"), "solo_enabled": "true", "gui_string": 32128, "art_type": "poster", "filename": "poster.jpg", }, { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_seasonposter"), "solo_enabled": "true", "gui_string": 32129, "art_type": "seasonposter", "filename": "season%02d-poster.jpg", }, { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_fanart"), "solo_enabled": "true", "gui_string": 32121, "art_type": "fanart", "filename": "fanart.jpg", }, { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_extrafanart"), "solo_enabled": "false", "gui_string": 32122, "art_type": "extrafanart", "filename": "", }, { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_clearart"), "solo_enabled": "true", "gui_string": 32125, "art_type": "clearart", "filename": "clearart.png", }, { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_logo"), "solo_enabled": "true", "gui_string": 32126, "art_type": "clearlogo", "filename": "logo.png", }, { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_landscape"), "solo_enabled": "true", "gui_string": 32130, "art_type": "landscape", "filename": "landscape.jpg", }, { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_seasonlandscape"), "solo_enabled": "true", "gui_string": 32134, "art_type": "seasonlandscape", "filename": "season%02d-landscape.jpg", }, { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_showbanner"), "solo_enabled": "true", "gui_string": 32123, "art_type": "banner", "filename": "banner.jpg", }, { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_seasonbanner"), "solo_enabled": "true", "gui_string": 32124, "art_type": "seasonbanner", "filename": "season%02d-banner.jpg", }, { "media_type": "tvshow", "bulk_enabled": setting.get("tvshow_characterart"), "solo_enabled": "true", "gui_string": 32127, "art_type": "characterart", "filename": "character.png", }, # Musicvideo { "media_type": "musicvideo", "bulk_enabled": setting.get("musicvideo_poster"), "solo_enabled": "true", "gui_string": 32128, "art_type": "poster", "filename": "poster.jpg", }, { "media_type": "musicvideo", "bulk_enabled": setting.get("musicvideo_fanart"), "solo_enabled": "true", "gui_string": 32121, "art_type": "fanart", "filename": "fanart.jpg", }, { "media_type": "musicvideo", "bulk_enabled": setting.get("musicvideo_extrafanart"), "solo_enabled": "false", "gui_string": 32122, "art_type": "extrafanart", "filename": "", }, { "media_type": "musicvideo", "bulk_enabled": setting.get("musicvideo_extrathumbs"), "solo_enabled": "false", "gui_string": 32131, "art_type": "extrathumbs", "filename": "thumb%s.jpg", }, { "media_type": "musicvideo", "bulk_enabled": setting.get("musicvideo_logo"), "solo_enabled": "true", "gui_string": 32126, "art_type": "clearlogo", "filename": "logo.png", }, { "media_type": "musicvideo", "bulk_enabled": setting.get("musicvideo_clearart"), "solo_enabled": "true", "gui_string": 32125, "art_type": "clearart", "filename": "clearart.png", }, { "media_type": "musicvideo", "bulk_enabled": setting.get("musicvideo_discart"), "solo_enabled": "true", "gui_string": 32132, "art_type": "cdart", "filename": "disc.png", }, ] return available_arttypes
def parse_args(parser, skip_depl_config=False): parsed_args = parser.parse_args() help_msg = "Run with the '-h' flag for additional help." if len(sys.argv) == 1: # print help when no args are provided parser.print_help() else: try: # if the version arg is present, print version and finish if parsed_args.version: log.info(settings.get("version")) return parsed_args used_depl_args = get_used_args_from_group(parsed_args, "deployment") used_mgmt_args = get_used_args_from_group(parsed_args, "management") # do not allow deployment args without using '--deploy' if len(used_depl_args) > 0 and "deploy" not in used_depl_args: first_offending_arg = get_first_used_arg_from_group( parsed_args, "deployment") parser.error( "Deployment arguments, such as '{0}', require '--deploy'.". format(first_offending_arg)) # do not allow management args if '--deploy' is used if parsed_args.deploy and len(used_mgmt_args) > 0: first_offending_arg = get_first_used_arg_from_group( parsed_args, "management") parser.error( "Management arguments, such as '{0}', are not allowed when using '--deploy'." .format(first_offending_arg)) str_central_conf = settings.get("custom_apache")["central_rule"] original_custom_file = fish.read_file( settings.get_custom_apache_conf_file_path()) # check for presence of the central arg if parsed_args.deploy and parsed_args.central: if str_central_conf not in original_custom_file: log.info( "Including apache rule for central monitoring in " + settings.get_custom_apache_conf_file_path()) original_custom_file = original_custom_file + str_central_conf fish.write_file( original_custom_file, settings.get_custom_apache_conf_file_path()) else: original_custom_file = original_custom_file.replace( str_central_conf, "") fish.write_file(original_custom_file, settings.get_custom_apache_conf_file_path()) if parsed_args.deploy and not skip_depl_config: # check for presence of required deployment args and validate them required_depl_args = get_required_depl_args() missing = list( filter(lambda x: x not in used_depl_args, required_depl_args)) if len(missing) > 0: parser.error( "Missing required deployment arguments: --{0}".format( ", --".join(missing))) else: if not fish.is_valid("domain", parsed_args.domain): parser.error("Invalid domain: '{0}'".format( parsed_args.domain)) if not fish.is_valid("email", parsed_args.email): parser.error("Invalid email: '{0}'".format( parsed_args.email)) # make '--letsencrypt' and '--no-port-binding' incompatible if parsed_args.letsencrypt and parsed_args.no_port_binding: parser.error( "Incompatible arguments: '--letsencrypt' and '--no-port-binding'. Cannot issue a Let's Encrypt certificate if port binding to host is disabled." ) # do not allow dots in the stack name if parsed_args.stack_name is not None and "." in parsed_args.stack_name: parser.error("The stack name cannot contain dots.") # validate advertise and proxy addresses, if present if parsed_args.addr and not fish.is_valid( "ip", parsed_args.addr): parser.error("Invalid IP address: '{0}'".format( parsed_args.addr)) if parsed_args.http_proxy and not fish.is_valid( "address", parsed_args.http_proxy): parser.error("Invalid proxy address: '{0}'".format( parsed_args.http_proxy)) if parsed_args.https_proxy and not fish.is_valid( "address", parsed_args.https_proxy): parser.error("Invalid proxy address: '{0}'".format( parsed_args.https_proxy)) else: # only allow one management argument at a time if len(used_mgmt_args) > 1: parser.error( "Only one management argument at a time is allowed.") except SystemExit as e: log_stdout.info("\n{0}".format(help_msg)) sys.exit(e) return parsed_args
def index(): setting = settings.get('what_credentials') if setting[1] == None or setting[1] == '': return render_template('settings.html', settings=settings.get_all(), message="Please set your whatcd username and password.", message_class="alert-error") torrents = torrent.get_recent() return render_template('index.html', torrents=torrents)
settings=settings.get_all(), message=output['message'], message_class=output['class'], userinfo=database.userinfo()) @app.route("/snatches") @requires_auth def snatches(): torrents = torrent.get_all() return render_template('snatches.html', torrents=torrents, userinfo=database.userinfo()) # Serve Static Assets @app.route('/assets/<path:filename>') def send_assets(filename): return send_from_directory('assets', filename) @app.route('/<path:filename>') def catch_all(filename): return send_from_directory('assets', filename) # It's Go Time if __name__ == "__main__": network_settings = settings.get('network') app.run(host=network_settings[1], port=int(network_settings[2]))
torrent.queue(request.form['data']) return "<button class='button' disabled>Snatched!</button>" @app.route("/group_info") @requires_auth def group_info(): group_id = request.args['id'] results = wat.get_group(group_id) return render_template('group_info.html', group_info=results) @app.route("/settings", methods=['GET', 'POST']) @requires_auth def settings_path(): output = {'message':None,'class':None} if request.method == 'POST': output = settings.update(request.form) wat.bust_handle_cache() return render_template('settings.html', settings=settings.get_all(), message=output['message'], message_class=output['class']) # Serve Static Assets @app.route('/assets/<path:filename>') def send_assets(filename): return send_from_directory('assets', filename) # It's Go Time if __name__ == "__main__": network_settings = settings.get('network') app.run(host=network_settings[1], port=int(network_settings[2]))