def new_secret_main(argv): """ prints a new storage secret to stdout """ from cli import build_base_options, parse_config optparser = build_base_options() opts, args, config = parse_config(argv, optparser, require_config=False) print new_secret()
def relay_main(argv): from cli import build_base_options, parse_config optparser = build_base_options() opts, args, config = parse_config(argv, optparser) storage = build_storage(config, opts) xmpp = build_relay(config, opts, storage) # Connect to the XMPP server and start processing XMPP stanzas. if xmpp.connect(): xmpp.process(block=True) print("Done") else: print("Unable to connect.")
def hash_main(argv): """ utility mainline for hashing and looking up jids. """ from cli import build_base_options, parse_config from jidstorage import build_storage, no_storage optparser = build_base_options() optparser.add_option('-S', '--store', help='store results', dest='build_storage', action="store_true", default=False) optparser.add_option( "-l", "--lookup", help='lookup real jid for hashed jid', dest="lookup", action="store_true", default=False) opts, args, config = parse_config(argv, optparser) if opts.build_storage == True or opts.lookup: storage = build_storage(config, opts) else: storage = no_storage() if opts.lookup == True: for hjid in args: real_jid = lookup_jid(JID(hjid), storage) print "%s => %s" % (hjid, real_jid) else: section = "hash" if not config.has_section(section): sys.exit("Configuration file %s is missing the [%s] section" % ( opts.config_file, section)) cfg = {} for key in ["secret", "domain"]: if not config.has_option(section, key): sys.exit('Missing option "%s" in [%s] section of %s' % (key, section, opts.config_file)) cfg[key] = config.get(section, key) for real_jid in args: hashed_jid = hash_jid( JID(real_jid), cfg['secret'], cfg['domain'], storage) print "%s => %s" % (real_jid, hashed_jid)
def test_parse_config(monkeypatch): monkeypatch.setattr(ConfigParser, "RawConfigParser", MockRawConfigParser) cfg = parse_config() assert isinstance(cfg, dict)
from cli import get_logger, parse_config from audio import load_mp3, get_jingles, glue_tracks, normalize_audio from publish import upload_file logger = get_logger() cfg = parse_config() # Read mp3 tags from config file mp3_tags = { 'title': cfg['title'], 'artist': cfg['artist'], 'album': cfg['album'], 'track': cfg['track'], 'comment': cfg['comment'], } logger.info("Importing podcast") podcast = load_mp3(cfg['podcast_file'], "podcast") logger.info("Generating jingles") opening, ending = get_jingles(cfg['song_file']) logger.info("Normalizing podcast audio") podcast = normalize_audio(podcast) logger.info("Generating final podcast file: opening + podcast + ending") final = glue_tracks([(opening, 0), (podcast, 1000), (ending, 4000)]) logger.info("Exporting final file") final.export( cfg['final_file'],