コード例 #1
0
ファイル: users.py プロジェクト: umonkey/ardj
def get_admins(safe=False):
    """Returns jids/emails of admins."""
    admins = settings.get2("jabber_admins", "jabber/access", [])
    if not safe:
        count = settings.get("promote_voters", 0)
        days = settings.get("promote_voters_days", 14)
        admins += get_top_recent_voters(count, days)
    return admins
コード例 #2
0
def get_config_option(name):
    try:
        from ardj import settings
        return settings.get(name)
    except Exception, e:
        log_error("Error getting config option %s: %s" % (name, e))
        log_error(traceback.format_exc(e))
コード例 #3
0
ファイル: mail.py プロジェクト: umonkey/ardj
    def get_body_vars(self):
        base_url = settings.get("web_api_root",
                                "http://localhost:8080").rstrip("/")
        link = "%s/auth?token=%s" % (base_url, self.token)

        return {
            "token": self.token,
            "link": link,
        }
コード例 #4
0
ファイル: mail.py プロジェクト: umonkey/ardj
    def get_template_data(self, suffix, default, vars=None):
        name = "%s_%s" % (self.__class__.__name__, suffix)

        template = settings.get(name, default)
        if template is None:
            return None

        if isinstance(vars, dict):
            template = template.format(**vars)

        return template
コード例 #5
0
ファイル: util.py プロジェクト: Alwnikrotikz/ardj
def upload_music(filenames):
    """Uploads music files."""
    target = settings.get('database/upload')
    if not target:
        logging.warning('Could not upload %u music files: database/upload not set.' % len(filenames))
        return False

    if type(filenames) != list:
        raise TypeError('filenames must be a list.')

    batch = mktemp(suffix='.txt')
    f = open(str(batch), 'wb')
    for fn in filenames:
        os.chmod(str(fn), 0664)
        f.write('put %s\n' % str(fn).replace(' ', '\\ '))
    f.close()

    return run(['sftp', '-b', str(batch), str(target)])
コード例 #6
0
ファイル: util.py プロジェクト: Alwnikrotikz/ardj
def _send_skip(confkey, default, sig):
    pidfile = settings.get(confkey, default)
    if not pidfile:
        logging.info("%s not set, can't send a skip request." % confkey)
        return False

    if not os.path.exists(pidfile):
        logging.warning("File %s does not exist -- can't send a skip request." % pidfile)
        return False

    pid = file(pidfile, "rb").read().strip()
    if not pid.isdigit():
        raise Exception("File %s does not contain a process id." % pidfile)

    try:
        os.kill(int(pid), sig)
        return True
    except Exception, e:
        logging.exception("Could not send a signal to ezstream: %s" % e)
        raise Exception("Could not send a skip request.  Details can be found in the log file.")
コード例 #7
0
def upload_music(filenames):
    """Uploads music files."""
    target = settings.get('database/upload')
    if not target:
        logging.warning(
            'Could not upload %u music files: database/upload not set.' %
            len(filenames))
        return False

    if type(filenames) != list:
        raise TypeError('filenames must be a list.')

    batch = mktemp(suffix='.txt')
    f = open(str(batch), 'wb')
    for fn in filenames:
        os.chmod(str(fn), 0664)
        f.write('put %s\n' % str(fn).replace(' ', '\\ '))
    f.close()

    return run(['sftp', '-b', str(batch), str(target)])