def get_revision_offset():
    try:
        revoffset = config.getint("log", "revision-offset", 0)
    except (ValueError, TypeError):
        raise Error, ("Invalid revision-offset number in configuration "
                      "file(s).")
    return revoffset or 0
Beispiel #2
0
def get_revision_offset():
    try:
        revoffset = config.getint("log", "revision-offset", 0)
    except (ValueError, TypeError):
        raise Error("Invalid revision-offset number in configuration "
                    "file(s).")
    return revoffset or 0
Beispiel #3
0
def submit(urls,
           target,
           define=[],
           submithost=None,
           port=None,
           atonce=False,
           debug=False,
           keeplog=False):
    if submithost is None:
        submithost = config.get("submit", "host")
        if submithost is None:
            raise Error, "no submit host defined in configuration"
    if port is None:
        port = config.getint("submit", "port", "22")

    # runs a create-srpm in the server through ssh, which will make a
    # copy of the rpm in the export directory
    createsrpm = get_helper("create-srpm")
    baseargs = ["ssh", "-p", str(port), submithost, createsrpm, "-t", target]
    if debug:
        baseargs.append("--debug")
    if keeplog:
        baseargs.append("--keeplog")
    for entry in reversed(define):
        baseargs.append("--define")
        baseargs.append(entry)
    cmdsargs = []
    if len(urls) == 1:
        # be compatible with server-side repsys versions older than 1.6.90
        url, rev = layout.split_url_revision(urls[0])
        baseargs.append("-r")
        baseargs.append(str(rev))
        baseargs.append(url)
        cmdsargs.append(baseargs)
    elif atonce:
        cmdsargs.append(baseargs + urls)
    else:
        cmdsargs.extend((baseargs + [url]) for url in urls)
    for cmdargs in cmdsargs:
        status, output = execcmd(cmdargs, noerror=1)
        if status == 0:
            print "Package submitted!"
        else:
            sys.stderr.write(output)
            sys.stderr.write("\n")
            sys.exit(status)
Beispiel #4
0
def is_binary(path):
    raw = config.get("binrepo", "upload-match",
            "\.(7z|Z|bin|bz2|cpio|db|deb|egg|gem|gz|jar|jisp|lzma|"\
               "pdf|pgn\\.gz|pk3|png|rpm|run|sdz|smzip|tar|tbz|"\
               "tbz2|tgz|ttf|uqm|wad|war|xar|xpi|xz|zip|wav|mp3|ogg|"\
        "jpg|png|gif|avi|mpg|mpeg|rar)$")
    maxsize = config.getint("binrepo", "upload-match-size", "1048576")  # 1MiB
    expr = re.compile(raw)
    name = os.path.basename(path)
    if expr.search(name):
        return True
    st = os.stat(path)
    if st[stat.ST_SIZE] >= maxsize:
        return True
    fd = open(path, 'rb')
    if b'\0' in bytes(fd.read(0x10000)):
        return True
    return False
Beispiel #5
0
def submit(urls, target, define=[], submithost=None, port=None,
        atonce=False, debug=False, keeplog=False):
    if submithost is None:
        submithost = config.get("submit", "host")
        if submithost is None:
            raise Error, "no submit host defined in configuration"
    if port is None:
        port = config.getint("submit", "port", "22")

    # runs a create-srpm in the server through ssh, which will make a
    # copy of the rpm in the export directory
    createsrpm = get_helper("create-srpm")
    baseargs = ["ssh", "-p", str(port), submithost, createsrpm,
            "-t", target]
    if debug:
        baseargs.append("--debug")
    if keeplog:
        baseargs.append("--keeplog")
    for entry in reversed(define):
        baseargs.append("--define")
        baseargs.append(entry)
    cmdsargs = []
    if len(urls) == 1:
        # be compatible with server-side repsys versions older than 1.6.90
        url, rev = layout.split_url_revision(urls[0])
        baseargs.append("-r")
        baseargs.append(str(rev))
        baseargs.append(url)
        cmdsargs.append(baseargs)
    elif atonce:
        cmdsargs.append(baseargs + urls)
    else:
        cmdsargs.extend((baseargs + [url]) for url in urls)
    for cmdargs in cmdsargs:
        status, output = execcmd(cmdargs, noerror=1)
        if status == 0:
            print "Package submitted!"
        else:
            sys.stderr.write(output)
            sys.stderr.write("\n")
            sys.exit(status)