Exemplo n.º 1
0
def products():
	products = reposadocommon.getProductInfo()
	catalog_branches = reposadocommon.getCatalogBranches()

	prodlist = []
	for prodid in products.keys():
		if 'title' in products[prodid] and 'version' in products[prodid] and 'PostDate' in products[prodid]:
			prod = {
				'title': products[prodid]['title'],
				'version': products[prodid]['version'],
				'PostDate': products[prodid]['PostDate'].strftime('%Y-%m-%d'),
				'description': get_description_content(products[prodid]['description']),
				'id': prodid,
				'depr': len(products[prodid].get('AppleCatalogs', [])) < 1,
				'branches': [],
				'oscatalogs': sorted(versions_from_catalogs(products[prodid].get('OriginalAppleCatalogs')), key=LooseVersion, reverse=True),
				'packages': product_urls(products[prodid]['CatalogEntry']),
				}

			for branch in catalog_branches.keys():
				if prodid in catalog_branches[branch]:
					prod['branches'].append(branch)

			prodlist.append(prod)
		else:
			print 'Invalid update!'

	sprodlist = sorted(prodlist, key=itemgetter('PostDate'), reverse=True)

	return json_response({'products': sprodlist, 'branches': catalog_branches.keys()})
Exemplo n.º 2
0
def process_queue():
    queue = json.loads(request.form['queue'])

    catalog_branches = reposadocommon.getCatalogBranches()
    
    for cat in queue['listing']:
	if cat not in catalog_branches.keys():
	    print 'No such catalog'
	    continue
	    
	for prodid in queue['listing'][cat]:
	    if prodid not in catalog_branches[cat]:
		# TODO: check for actual prodid?
		print 'Adding product',prodid,'to cat',cat
		catalog_branches[cat].append(prodid)

    for cat in queue['delisting']:
	if cat not in catalog_branches.keys():
	    print 'No such catalog'
	    continue
	    
	for prodid in queue['delisting'][cat]:
	    if prodid in catalog_branches[cat]:
		print 'Removing product',prodid,'from cat',cat
		catalog_branches[cat].remove(prodid)

    reposadocommon.writeCatalogBranches(catalog_branches)
    reposadocommon.writeAllBranchCatalogs()

    
    return jsonify(result=True);
def products():
    products = reposadocommon.getProductInfo()
    catalog_branches = reposadocommon.getCatalogBranches()

    prodlist = []
    for prodid in products.keys():
        if 'title' in products[prodid] and 'version' in products[prodid] \
           and 'PostDate' in products[prodid]:
            prod = {
                'title': products[prodid]['title'],
                'version': products[prodid]['version'],
                'PostDate': products[prodid]['PostDate'].strftime('%Y-%m-%d'),
                'description': get_description_content(
                    products[prodid]['description']),
                'id': prodid,
                'depr': len(products[prodid].get('AppleCatalogs', [])) < 1,
                'branches': [],
                'oscatalogs': sorted(
                    versions_from_catalogs(products[prodid].get(
                        'OriginalAppleCatalogs')),
                    key=LooseVersion, reverse=True),
                'packages': product_urls(products[prodid]['CatalogEntry']), }

            for branch in catalog_branches.keys():
                if prodid in catalog_branches[branch]:
                    prod['branches'].append(branch)

            prodlist.append(prod)
        else:
            print 'Invalid update!'

    sprodlist = sorted(prodlist, key=itemgetter('PostDate'), reverse=True)

    return json_response({
        'products': sprodlist, 'branches': catalog_branches.keys()})
Exemplo n.º 4
0
def process_queue():
	catalog_branches = reposadocommon.getCatalogBranches()

	for change in request.json:
		prodId = change['productId']
		branch = change['branch']

		if branch not in catalog_branches.keys():
			print 'No such catalog'
			continue
		
		if change['listed']:
			# if this change /was/ listed, then unlist it
			if prodId in catalog_branches[branch]:
				print 'Removing product %s from branch %s' % (prodId, branch, )
				catalog_branches[branch].remove(prodId)
		else:
			# if this change /was not/ listed, then list it
			if prodId not in catalog_branches[branch]:
				print 'Adding product %s to branch %s' % (prodId, branch, )
				catalog_branches[branch].append(prodId)

	print 'Writing catalogs'
	reposadocommon.writeCatalogBranches(catalog_branches)
	reposadocommon.writeAllBranchCatalogs()

	return jsonify(result=True)
Exemplo n.º 5
0
def process_queue():
    queue = json.loads(request.form["queue"])

    catalog_branches = reposadocommon.getCatalogBranches()

    for cat in queue["listing"]:
        if cat not in catalog_branches.keys():
            print "No such catalog"
            continue

        for prodid in queue["listing"][cat]:
            if prodid not in catalog_branches[cat]:
                # TODO: check for actual prodid?
                print "Adding product", prodid, "to cat", cat
                catalog_branches[cat].append(prodid)

    for cat in queue["delisting"]:
        if cat not in catalog_branches.keys():
            print "No such catalog"
            continue

        for prodid in queue["delisting"][cat]:
            if prodid in catalog_branches[cat]:
                print "Removing product", prodid, "from cat", cat
                catalog_branches[cat].remove(prodid)

    reposadocommon.writeCatalogBranches(catalog_branches)
    reposadocommon.writeAllBranchCatalogs()

    return jsonify(result=True)
def process_queue():
    catalog_branches = reposadocommon.getCatalogBranches()

    for change in request.json:
        prodId = change['productId']
        branch = change['branch']

        if branch not in catalog_branches.keys():
            print 'No such catalog'
            continue

        if change['listed']:
            # if this change /was/ listed, then unlist it
            if prodId in catalog_branches[branch]:
                print 'Removing product %s from branch %s' % (prodId, branch, )
                catalog_branches[branch].remove(prodId)
        else:
            # if this change /was not/ listed, then list it
            if prodId not in catalog_branches[branch]:
                print 'Adding product %s to branch %s' % (prodId, branch, )
                catalog_branches[branch].append(prodId)

    print 'Writing catalogs'
    reposadocommon.writeCatalogBranches(catalog_branches)
    reposadocommon.writeAllBranchCatalogs()

    return jsonify(result=True)
Exemplo n.º 7
0
def process_queue():
    queue = json.loads(request.form['queue'])

    catalog_branches = reposadocommon.getCatalogBranches()

    for cat in queue['listing']:
        if cat not in catalog_branches.keys():
            print 'No such catalog'
            continue

        for prodid in queue['listing'][cat]:
            if prodid not in catalog_branches[cat]:
                # TODO: check for actual prodid?
                print 'Adding product', prodid, 'to cat', cat
                catalog_branches[cat].append(prodid)

    for cat in queue['delisting']:
        if cat not in catalog_branches.keys():
            print 'No such catalog'
            continue

        for prodid in queue['delisting'][cat]:
            if prodid in catalog_branches[cat]:
                print 'Removing product', prodid, 'from cat', cat
                catalog_branches[cat].remove(prodid)

    reposadocommon.writeCatalogBranches(catalog_branches)
    reposadocommon.writeAllBranchCatalogs()

    return jsonify(result=True)
def new_branch(branchname):
    catalog_branches = reposadocommon.getCatalogBranches()
    if branchname in catalog_branches:
        reposadocommon.print_stderr('Branch %s already exists!', branchname)
        abort(401)
    catalog_branches[branchname] = []
    reposadocommon.writeCatalogBranches(catalog_branches)

    return jsonify(result='success')
Exemplo n.º 9
0
def new_branch(branchname):
    catalog_branches = reposadocommon.getCatalogBranches()
    if branchname in catalog_branches:
        reposadocommon.print_stderr('Branch %s already exists!', branchname)
        abort(401)
    catalog_branches[branchname] = []
    reposadocommon.writeCatalogBranches(catalog_branches)
    
    return jsonify(result='success')
Exemplo n.º 10
0
def list_branches():
    '''Returns catalog branch names and associated updates'''
    catalog_branches = reposadocommon.getCatalogBranches()

    # reorganize the updates into an array of branches
    branches = []
    for branch in catalog_branches.keys():
        branches.append({'name': branch, 'products': catalog_branches[branch]})

    return json_response(branches)
Exemplo n.º 11
0
def add_all(branchname):
	products = reposadocommon.getProductInfo()
	catalog_branches = reposadocommon.getCatalogBranches()
	
	catalog_branches[branchname] = products.keys()

	reposadocommon.writeCatalogBranches(catalog_branches)
	reposadocommon.writeAllBranchCatalogs()
	
	return jsonify(result=True)
Exemplo n.º 12
0
def list_branches():
	'''Returns catalog branch names and associated updates'''
	catalog_branches = reposadocommon.getCatalogBranches()

	# reorganize the updates into an array of branches
	branches = []
	for branch in catalog_branches.keys():
		branches.append({'name': branch, 'products': catalog_branches[branch]})

	return json_response(branches)
def add_all(branchname):
    products = reposadocommon.getProductInfo()
    catalog_branches = reposadocommon.getCatalogBranches()

    catalog_branches[branchname] = products.keys()

    reposadocommon.writeCatalogBranches(catalog_branches)
    reposadocommon.writeAllBranchCatalogs()

    return jsonify(result=True)
Exemplo n.º 14
0
def diff_branches(branch_list):
    '''Displays differences between two branches'''
    catalog_branches = reposadocommon.getCatalogBranches()
    for branch in branch_list:
        if branch not in catalog_branches:
            reposadocommon.print_stderr(
                'ERROR: %s is not a valid branch name.' % branch)
            return
    branch1 = set(catalog_branches[branch_list[0]])
    branch2 = set(catalog_branches[branch_list[1]])
    unique_to_first = branch1 - branch2
    if len(unique_to_first) == 0:
        print('No items to move.')
Exemplo n.º 15
0
def dup(frombranch, tobranch):
	catalog_branches = reposadocommon.getCatalogBranches()

	if frombranch not in catalog_branches.keys() or tobranch not in catalog_branches.keys():
		print 'No branch ' + branchname
		return jsonify(result=False)

	catalog_branches[tobranch] = catalog_branches[frombranch]

	print 'Writing catalogs'
	reposadocommon.writeCatalogBranches(catalog_branches)
	reposadocommon.writeAllBranchCatalogs()

	return jsonify(result=True)
Exemplo n.º 16
0
def configure_prefs():
    """Configures prefs for use"""
    _prefs = {}
    keysAndPrompts = [
        ('ReposadoBranchOrderList', 'Arrange Reposado Branches for automation.'
         '\nTo arrange. (y) \nUse existing. (Enter)'
         '\nExit. (Ctrl-C)'
         '\nCurrent Config:'),
        ('MunkiPkginfoPath', '\nPath to put Apple Software Update pkginfo'
         ' metadata in munki.'),
        ('DaysTillForceInstall', '\nNumber of days from munki import to '
         'set force installs.'),
        ('ForceInstallHour', '\nHour of the day to set munki force install '
         '(24 Hour time).'),
        ('ForceInstallMinute', '\nMinute of the hour to set munki force '
         'install.'),
        ('MunkiCatalog', '\nName of munki catalog for software update'
         ' metadata.')
    ]

    for (key, prompt) in keysAndPrompts:
        newvalue = raw_input('{0} [{1}]: '.format(prompt, pref(key)))
        newvalue = newvalue or pref(key) or ''
        try:
            if key == 'ReposadoBranchOrderList' and newvalue.lower() == 'y':
                cur_branches = reposadocommon.getCatalogBranches().keys()
                newvalue = arrange_branches(cur_branches)
        except AttributeError:
            pass
        _prefs[key] = newvalue or pref(key) or ''
    toddy_plist = pref_file()
    try:
        old_prefs = plistlib.readPlist(toddy_plist)
    except IOError as e:
        old_prefs = {}
    for key, value in old_prefs.iteritems():
        if key not in _prefs.keys():
            _prefs[key] = value
    if _prefs['ReposadoBranchOrderList'] == 'y':
        print('WARNING: Please setup reposado with at least two branches '
              'to use repotoddy...')
        _prefs['ReposadoBranchOrderList'] = []
    plistlib.writePlist(_prefs, toddy_plist)
def dup_apple(branchname):
    catalog_branches = reposadocommon.getCatalogBranches()

    if branchname not in catalog_branches.keys():
        print 'No branch ' + branchname
        return jsonify(result=False)

    # generate list of (non-deprecated) updates
    products = reposadocommon.getProductInfo()
    prodlist = []
    for prodid in products.keys():
        if len(products[prodid].get('AppleCatalogs', [])) >= 1:
            prodlist.append(prodid)

    catalog_branches[branchname] = prodlist

    print 'Writing catalogs'
    reposadocommon.writeCatalogBranches(catalog_branches)
    reposadocommon.writeAllBranchCatalogs()

    return jsonify(result=True)
Exemplo n.º 18
0
def dup_apple(branchname):
	catalog_branches = reposadocommon.getCatalogBranches()

	if branchname not in catalog_branches.keys():
		print 'No branch ' + branchname
		return jsonify(result=False)

	# generate list of (non-deprecated) updates
	products = reposadocommon.getProductInfo()
	prodlist = []
	for prodid in products.keys():
		if len(products[prodid].get('AppleCatalogs', [])) >= 1:
			prodlist.append(prodid)

	catalog_branches[branchname] = prodlist

	print 'Writing catalogs'
	reposadocommon.writeCatalogBranches(catalog_branches)
	reposadocommon.writeAllBranchCatalogs()

	return jsonify(result=True)
Exemplo n.º 19
0
def delete_branch(branchname):
    catalog_branches = reposadocommon.getCatalogBranches()
    if not branchname in catalog_branches:
        reposadocommon.print_stderr("Branch %s does not exist!", branchname)
        return

    del catalog_branches[branchname]

    # this is not in the common library, so we have to duplicate code
    # from repoutil
    for catalog_URL in reposadocommon.pref("AppleCatalogURLs"):
        localcatalogpath = reposadocommon.getLocalPathNameFromURL(catalog_URL)
        # now strip the '.sucatalog' bit from the name
        if localcatalogpath.endswith(".sucatalog"):
            localcatalogpath = localcatalogpath[0:-10]
        branchcatalogpath = localcatalogpath + "_" + branchname + ".sucatalog"
        if os.path.exists(branchcatalogpath):
            reposadocommon.print_stdout("Removing %s", os.path.basename(branchcatalogpath))
            os.remove(branchcatalogpath)

    reposadocommon.writeCatalogBranches(catalog_branches)

    return jsonify(result=True)
Exemplo n.º 20
0
def delete_branch(branchname):
    catalog_branches = reposadocommon.getCatalogBranches()
    if not branchname in catalog_branches:
        reposadocommon.print_stderr('Branch %s does not exist!', branchname)
        return

    del catalog_branches[branchname]

    # this is not in the common library, so we have to duplicate code
    # from repoutil
    for catalog_URL in reposadocommon.pref('AppleCatalogURLs'):
        localcatalogpath = reposadocommon.getLocalPathNameFromURL(catalog_URL)
        # now strip the '.sucatalog' bit from the name
        if localcatalogpath.endswith('.sucatalog'):
            localcatalogpath = localcatalogpath[0:-10]
        branchcatalogpath = localcatalogpath + '_' + branchname + '.sucatalog'
        if os.path.exists(branchcatalogpath):
            reposadocommon.print_stdout(
                'Removing %s', os.path.basename(branchcatalogpath))
            os.remove(branchcatalogpath)

    reposadocommon.writeCatalogBranches(catalog_branches)
    
    return jsonify(result=True);
def list_branches():
    '''Returns catalog branch names and associated updates'''
    catalog_branches = reposadocommon.getCatalogBranches()

    return json_response(catalog_branches.keys())
Exemplo n.º 22
0
def list_branches():
	'''Returns catalog branch names and associated updates'''
	catalog_branches = reposadocommon.getCatalogBranches()

	return json_response(catalog_branches.keys())
Exemplo n.º 23
0
def list_branches():
    '''Returns catalog branch names'''
    catalog_branches = reposadocommon.getCatalogBranches()
    return jsonify(result=catalog_branches)
Exemplo n.º 24
0
def list_branches():
    '''Returns catalog branch names'''
    catalog_branches = reposadocommon.getCatalogBranches()
    return jsonify(result=catalog_branches)