All pastes #613457 Raw Edit

Stuff

public text v1 · immutable
·published 2007-07-11 00:04 UTC
rendered paste body

#!/usr/bin/python

import sys
import os
import deb822
import subprocess
import string

home = '/home/ryan/'
incomming = home + 'pbuilder/incomming/'
queued = home + 'pbuilder/queued/'
processed = home + 'pbuilder/processed'
logs = '/var/www/blog.ryanak.ca/web/logs/'

def get_filenames(f):
    base = os.path.dirname(f)
    if f.endswith('.dsc'):
        d = deb822.Dsc(file(f))
    elif f.endswith('.changes'):
        d = deb822.Changes(file(f))
    return [os.path.join(base, elt['name']) for elt in d['Files']] + [f]

def check_and_create_queued(queued_dir, filename):
    # Checks the Queued dir to see if the subirectory exists
    # if it doesn't, create it!
    base = filename.split('_')[0]
    for item in os.listdir(queued_dir):
        if item == base:
            exists = True
    if exists != True:
        os.mkdir(queued + base)

incomming_files = os.listdir(incomming)

for file in incomming_files:
    if file.endswith('.dsc'):
        files_to_move_to_queue = get_filenames(file)

for file in files_to_move_to_queue:
    # Move files to subdirectory in queued
    incomming_file = incomming + file
    exists = False
    if exists != True:
        check_and_create_queued(queued, file)
        exists = True
    queued_file = queued + file.split('_')[0] + '/' + file
    os.rename(incomming_file, queued_file)

#p = subprocess.Popen('pbuilder-' + distro + ' build' + dsc, stdout=subprocess.PIPE)
#p.wait()
#p.stdout.readlines()