2
2
# licensed under the GNU Affero General Public License version 3 (see
9
from utils import parse_branch
11
from config import CHARM_IMPORT_FILTER
12
from config import CHARM_IMPORT_LIMIT
13
7
from config import LP_OUT_QUEUE
14
8
from utils import get_queues
16
BRANCH_TIPS = "https://api.launchpad.net/devel/charm?ws.op=getBranchTips"
19
log = logging.getLogger("charm.launchpad")
22
def available_charms(charm_data=None):
24
charm_data = urllib.urlopen(BRANCH_TIPS).read()
25
charm_data = json.loads(charm_data)
29
for repo, commit, series in charm_data:
30
_, branch_name = repo.rsplit("/", 1)
33
data = parse_branch(repo, series, commit)
35
log.warning("Unable to parse repo %s", repo)
38
if CHARM_IMPORT_FILTER and not data['branch_spec'].startswith(
42
if data["bname"] not in ("trunk", "trunk-1"):
43
log.debug("Skipped branch %s", repo)
46
log.info("Queueing %s", data['branch_spec'])
51
if CHARM_IMPORT_LIMIT and count >= CHARM_IMPORT_LIMIT:
52
log.info("Import limit reached (%d)... stopping",
57
def queue_charms(out_queue):
58
for charm in available_charms():
59
added = out_queue.put(charm)
61
log.info("Queued %s", charm)
9
from worker import queue_charms
12
if __name__ == '__main__':
65
13
logging.basicConfig(
66
14
level=logging.INFO,
67
15
format="%(asctime)s: %(name)s@%(levelname)s: %(message)s")
68
16
out_queue = get_queues(LP_OUT_QUEUE)
69
17
queue_charms(out_queue)
72
if __name__ == '__main__':