rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if 'aliases' in item: for alias in item['aliases']: if alias in pkgdata['receipts_for_name']: return pkgdata['receipts_for_name'][alias]
def getReceiptsToRemove(item): name = item['name'] if name in pkgdata['receipts_for_name']: return pkgdata['receipts_for_name'][name] # now check aliases if 'aliases' in item: for alias in item['aliases']: if alias in pkgdata['receipts_for_name']: return pkgdata['receipts_for_name'][alias] # found nothing return []
uninstall_item_names.extend(uninstall_item.get('aliases',[]))
def processRemoval(manifestitem, cataloglist, installinfo): """ Processes a manifest item; attempts to determine if it needs to be removed, and if it can be removed. Unlike installs, removals aren't really version-specific - If we can figure out how to remove the currently installed version, we do, unless the admin sp...
namesandaliases.extend(item_pl.get('aliases',[]))
def processRemoval(manifestitem, cataloglist, installinfo): """ Processes a manifest item; attempts to determine if it needs to be removed, and if it can be removed. Unlike installs, removals aren't really version-specific - If we can figure out how to remove the currently installed version, we do, unless the admin sp...
return '0.6.0 Build 759'
return '0.7.0 Build 8xx'
def get_version(): """Returns version of munkitools""" return '0.6.0 Build 759'
FoundationPlist.writePlist(_prefs, prefsfile)
FoundationPlist.writePlist(_prefs, MANAGED_INSTALLS_PLIST_PATH)
def prefs(force_refresh=False): """Loads and caches preferences from ManagedInstalls.plist. Args: force_refresh: Boolean. If True, wipe prefs and reload from scratch. If False (default), load from cache if it's already set. Returns: Dict of preferences. """ global _prefs if not _prefs or force_refresh: _prefs = {} #...
iteminfo['installer_item_size'] = item_pl.get('installer_item_size', 0)
iteminfo['installer_item_size'] = \ item_pl.get('installer_item_size', 0)
def processOptionalInstall(manifestitem, cataloglist, installinfo): """Process an optional install item to see if it should be added to the list of optional installs. """ manifestitemname = os.path.split(manifestitem)[1] item_pl = getItemDetail(manifestitem, cataloglist) if not item_pl: munkicommon.display_warning( 'C...
munkicommon.display_debug2('Our OS version is %s' %
munkicommon.display_debug1('Our OS version is %s' %
def compare_version_keys(a, b): """Internal comparison function for use in sorting""" return cmp(version.LooseVersion(b), version.LooseVersion(a))
(output, err) = proc.communicate()
(output, unused_err) = proc.communicate()
def install(pkgpath, choicesXMLpath=None, suppressBundleRelocation=False): """ Uses the apple installer to install the package or metapackage at pkgpath. Prints status messages to STDOUT. Returns a tuple: the installer return code and restart needed as a boolean. """ restartneeded = False installeroutput = [] if os.p...
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate()
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, unused_err) = proc.communicate()
def copyAppFromDMG(dmgpath): '''copies application from DMG to /Applications''' munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = munkicommon.mountdmg(dmgpath) if mountpoints: retcode = 0 appname = None mountpoint = mountpoints[0] # find an app at the root level, copy it to ...
err = subprocess.call(["/usr/bin/xattr", "-d", "com.apple.quarantine", destpath])
unused_result = subprocess.call( ["/usr/bin/xattr", "-d", "com.apple.quarantine", destpath])
def copyAppFromDMG(dmgpath): '''copies application from DMG to /Applications''' munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = munkicommon.mountdmg(dmgpath) if mountpoints: retcode = 0 appname = None mountpoint = mountpoints[0] # find an app at the root level, copy it to ...
(out, err) = proc.communicate()
(out, unused_err) = proc.communicate()
def copyFromDMG(dmgpath, itemlist): '''copies items from DMG to local disk''' if not itemlist: munkicommon.display_error("No items to copy!") return -1 munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = munkicommon.mountdmg(dmgpath) if mountpoints: mountpoint = mountpoints[0...
err = subprocess.call(["/usr/bin/xattr", "-d", "com.apple.quarantine", destitem])
unused_result = subprocess.call( ["/usr/bin/xattr", "-d", "com.apple.quarantine", destitem])
def copyFromDMG(dmgpath, itemlist): '''copies items from DMG to local disk''' if not itemlist: munkicommon.display_error("No items to copy!") return -1 munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = munkicommon.mountdmg(dmgpath) if mountpoints: mountpoint = mountpoints[0...
"Setting owner for '%s'" % destitem)
"Setting owner for '%s' to '%s'" % (destitem, item['user']))
def copyFromDMG(dmgpath, itemlist): # copies items from DMG if not itemlist: munkicommon.display_error("No items to copy!") return -1 munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = munkicommon.mountdmg(dmgpath) if mountpoints: mountpoint = mountpoints[0] retcode = 0 for ...
"Setting group for '%s'" % destitem)
"Setting group for '%s' to '%s'" % (destitem, item['group']))
def copyFromDMG(dmgpath, itemlist): # copies items from DMG if not itemlist: munkicommon.display_error("No items to copy!") return -1 munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = munkicommon.mountdmg(dmgpath) if mountpoints: mountpoint = mountpoints[0] retcode = 0 for ...
munkicommon.display_detail("Setting mode for '%s'" % destitem) cmd = ['/bin/chmod', '-R', options['mode'], destitem]
munkicommon.display_detail( "Setting mode for '%s' to '%s'" % (destitem, item['mode'])) cmd = ['/bin/chmod', '-R', item['mode'], destitem]
def copyFromDMG(dmgpath, itemlist): # copies items from DMG if not itemlist: munkicommon.display_error("No items to copy!") return -1 munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = munkicommon.mountdmg(dmgpath) if mountpoints: mountpoint = mountpoints[0] retcode = 0 for ...
if display_name in item:
if 'display_name' in item:
def getAvailableUpdates(self): updatelist = [] installinfo = munki.getInstallInfo() if installinfo: updatelist = installinfo.get("managed_installs", []) if installinfo.get("removals"): removallist = installinfo.get("removals") restartNeeded = False showRemovalDetail = munki.getRemovalDetailPrefs() for item in removalli...
else:
if osvers > 9:
def initDatabase(packagedb,forcerebuild=False): """ Builds or rebuilds our internal package database. """ if not shouldRebuildDB(packagedb) and not forcerebuild: return True munkicommon.display_status('Gathering information on installed packages') if os.path.exists(packagedb): try: os.remove(packagedb) except (OSErro...
for i in range(10):
pid = None for i in range(8):
def getMunkiStatusSocket(): for i in range(10): pid = getMunkiStatusPID() if pid: socketpath = "/tmp/com.googlecode.munki.munkistatus.%s" % pid if os.path.exists(socketpath): return socketpath else: # sleep and try again time.sleep(.5) return ""
else: time.sleep(.5)
time.sleep(.25)
def getMunkiStatusSocket(): for i in range(10): pid = getMunkiStatusPID() if pid: socketpath = "/tmp/com.googlecode.munki.munkistatus.%s" % pid if os.path.exists(socketpath): return socketpath else: # sleep and try again time.sleep(.5) return ""
retcode = adobeutils.runAdobeSetup(itempath, uninstalling=True)
retcode = runAdobeSetup(itempath, uninstalling=True)
def doAdobeRemoval(item): uninstallmethod = item['uninstall_method'] itempath = "" if "uninstaller_item" in item: managedinstallbase = munkicommon.pref('ManagedInstallDir') itempath = os.path.join(managedinstallbase, 'Cache', item["uninstaller_item"]) if not os.path.exists(itempath): munkicommon.display_error("%s packa...
raise CurlError(-2, "No CA directory at %s" % cadir)
raise CurlError(-2, "No CA directory at %s" % capath)
def curl(url, destinationpath, onlyifnewer=False, etag=None, resume=False, cacert=None, capath=None, cert=None, key=None, message=None): """Gets an HTTP or HTTPS URL and stores it in destination path. Returns a dictionary of headers, which includes http_result_code and http_result_description. Will raise CurlError if c...
os.unlink(usermanifest)
try: os.unlink(usermanifest) except OSErr: pass
def check(client_id=''): '''Checks for available new or updated managed software, downloading installer items if needed. Returns 1 if there are available updates, 0 if there are no available updates, and -1 if there were errors.''' getMachineFacts() munkicommon.report['MachineInfo'] = machine ManagedInstallDir = munki...
cataloglist = getManifestValueForKey(mainmanifestpath, 'catalogs')
def check(client_id=''): '''Checks for available new or updated managed software, downloading installer items if needed. Returns 1 if there are available updates, 0 if there are no available updates, and -1 if there were errors.''' getMachineFacts() munkicommon.report['MachineInfo'] = machine ManagedInstallDir = munki...
removed_items = [item for item in installinfo['removals'] if item.get('installed') == False]
removed_items = [item.get('manifestitem') for item in installinfo['removals'] if item.get('installed') == False] if os.path.exists(selfservemanifest): try: plist = FoundationPlist.readPlist(selfservemanifest) except FoundationPlist.FoundationPlistException: pass else: managed_uninstalls = plist.get('managed_uninsta...
def check(client_id=''): '''Checks for available new or updated managed software, downloading installer items if needed. Returns 1 if there are available updates, 0 if there are no available updates, and -1 if there were errors.''' getMachineFacts() munkicommon.report['MachineInfo'] = machine ManagedInstallDir = munki...
munkicommon.display_debug1( 'Getting info on currently installed applications...')
display_debug1('Getting info on currently installed applications...')
def getAppData(): """Queries system_profiler and returns a dict of app info items.""" global APPDICT if APPDICT == {}: munkicommon.display_debug1( 'Getting info on currently installed applications...') cmd = ['/usr/sbin/system_profiler', '-XML', 'SPApplicationsDataType'] proc = subprocess.Popen(cmd, shell=False, bufsiz...
print >>sys.stderr, "Error %s mounting %s." % (err, dmgpath)
print >> sys.stderr, "Error %s mounting %s." % (err, dmgname)
def mountAdobeDmg(dmgpath): """ Attempts to mount the dmg at dmgpath and returns a list of mountpoints """ mountpoints = [] dmgname = os.path.basename(dmgpath) p = subprocess.Popen(['/usr/bin/hdiutil', 'attach', dmgpath, '-nobrowse', '-noverify', '-plist'], bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (pl...
try: for item in os.listdir(tmpsetupdir): os.remove(os.path.join(tmpsetupdir, item)) os.rmdir(tmpsetupdir) os.remove(os.path.join(tmpdir, "ASU")) os.remove(os.path.join(tmpdir, "ProvisioningTool")) os.rmdir(tmpdir) except OSError: pass
ignoreresult = subprocess.call(["/bin/rm", "-rf", tmpdir])
def runAdobeCS5AAMEEInstall(dmgpath): '''Installs a CS5 product using an AAMEE-generated package on a disk image.''' munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = mountAdobeDmg(dmgpath) if not mountpoints: munkicommon.display_error("No mountable filesystems on %s" % dmgp...
def runAdobeCS5PatchInstaller(dmgpath):
def runAdobeCS5PatchInstaller(dmgpath, copylocal=False):
def runAdobeCS5PatchInstaller(dmgpath): munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = mountAdobeDmg(dmgpath) if mountpoints: patchinstaller = findAdobePatchInstallerApp(mountpoints[0]) if patchinstaller: # try to find and count the number of payloads # so we can give a r...
patchinstaller = findAdobePatchInstallerApp(mountpoints[0])
if copylocal: updatedir = tempfile.mkdtemp() retcode = subprocess.call(["/bin/cp", "-r", mountpoints[0], updatedir]) munkicommon.unmountdmg(mountpoints[0]) if retcode: munkicommon.display_error( "Error copying items from %s" % dmgpath) return -1 ignoreresult = subprocess.call(["/bin/rm", dmgpath]) else: updatedir =...
def runAdobeCS5PatchInstaller(dmgpath): munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = mountAdobeDmg(dmgpath) if mountpoints: patchinstaller = findAdobePatchInstallerApp(mountpoints[0]) if patchinstaller: # try to find and count the number of payloads # so we can give a r...
number_of_payloads = countPayloads(mountpoints[0])
number_of_payloads = countPayloads(updatedir)
def runAdobeCS5PatchInstaller(dmgpath): munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = mountAdobeDmg(dmgpath) if mountpoints: patchinstaller = findAdobePatchInstallerApp(mountpoints[0]) if patchinstaller: # try to find and count the number of payloads # so we can give a r...
munkicommon.unmountdmg(mountpoints[0])
if copylocal: ignoreresult = subprocess.call(["/bin/rm", "-rf", updatedir]) else: munkicommon.unmountdmg(mountpoints[0])
def runAdobeCS5PatchInstaller(dmgpath): munkicommon.display_status("Mounting disk image %s" % os.path.basename(dmgpath)) mountpoints = mountAdobeDmg(dmgpath) if mountpoints: patchinstaller = findAdobePatchInstallerApp(mountpoints[0]) if patchinstaller: # try to find and count the number of payloads # so we can give a r...
retcode = runAdobeCS5PatchInstaller(itempath)
retcode = runAdobeCS5PatchInstaller(itempath, copylocal=item.get("copy_local"))
def doAdobeInstall(item): # wrapper to handle all the Adobe installer methods # first get the path to the installer dmg. We know # it exists because installer.py already checked managedinstallbase = \ munkicommon.pref('ManagedInstallDir') itempath = os.path.join(managedinstallbase, 'Cache', item["installer_item"]) inst...
if not output.contains("Missing bundle identifier"):
if "Missing bundle identifier" not in output:
def checkForSoftwareUpdates(): '''Does our Apple Software Update check''' if munkicommon.munkistatusoutput: munkistatus.message("Checking for available " "Apple Software Updates...") munkistatus.detail("") munkistatus.percent(-1) else: munkicommon.display_status("Checking for available " "Apple Software Updates...") # ...
elif name in item:
elif 'name' in item:
def getAvailableUpdates(self): updatelist = [] installinfo = munki.getInstallInfo() if installinfo: updatelist = installinfo.get("managed_installs", []) if installinfo.get("removals"): removallist = installinfo.get("removals") restartNeeded = False showRemovalDetail = munki.getRemovalDetailPrefs() for item in removalli...
softwareUpdatePrefs().get('LastSuccessfulDate'))
softwareUpdatePrefs().get('LastSuccessfulDate', ''))
def appleSoftwareUpdatesAvailable(forcecheck=False, suppresscheck=False): '''Checks for available Apple Software Updates, trying not to hit the SUS more than needed''' # have we already processed the list of Apple Updates? updatesindexfile = '/Library/Updates/index.plist' if os.path.exists(appleUpdatesFile) and os.path...
def download_installeritem(item_pl): """Downloads a installer item. Raises an error if there are issues...""" location = item_pl.get('installer_item_location')
def download_installeritem(item_pl, uninstalling=False): """Downloads an (un)installer item. Raises an error if there are issues...""" download_item_key = 'installer_item_location' item_hash_key = 'installer_item_hash' if uninstalling and 'uninstaller_item_location' in item_pl: download_item_key = 'uninstaller_item_lo...
def download_installeritem(item_pl): """Downloads a installer item. Raises an error if there are issues...""" location = item_pl.get('installer_item_location') if not location: raise MunkiDownloadError("No installer_item_location in item info.") ManagedInstallDir = munkicommon.pref('ManagedInstallDir') downloadbaseurl...
raise MunkiDownloadError("No installer_item_location in item info.")
raise MunkiDownloadError("No %s in item info." % download_item_key)
def download_installeritem(item_pl): """Downloads a installer item. Raises an error if there are issues...""" location = item_pl.get('installer_item_location') if not location: raise MunkiDownloadError("No installer_item_location in item info.") ManagedInstallDir = munkicommon.pref('ManagedInstallDir') downloadbaseurl...
'installer_item_hash'):
item_hash_key):
def download_installeritem(item_pl): """Downloads a installer item. Raises an error if there are issues...""" location = item_pl.get('installer_item_location') if not location: raise MunkiDownloadError("No installer_item_location in item info.") ManagedInstallDir = munkicommon.pref('ManagedInstallDir') downloadbaseurl...
download_installeritem(item)
download_installeritem(item, uninstalling=True)
def processRemoval(manifestitem, cataloglist, installinfo): """Processes a manifest item; attempts to determine if it needs to be removed, and if it can be removed. Unlike installs, removals aren't really version-specific - If we can figure out how to remove the currently installed version, we do, unless the admin spe...
if not newmanifest:
if err or not newmanifest:
def getmanifest(partialurl, suppress_errors=False): """ Gets a manifest from the server """ manifestbaseurl = munkicommon.pref('ManifestURL') or \ munkicommon.pref('SoftwareRepoURL') + "/manifests/" if not manifestbaseurl.endswith('?') and \ not manifestbaseurl.endswith('/'): manifestbaseurl = manifestbaseurl + "/" mun...
for item in installinfo.get('removals',[])])
for item in installinfo.get('removals',[]) if item.get('uninstaller_item')])
def check(id=''): '''Checks for available new or updated managed software, downloading installer items if needed. Returns 1 if there are available updates, 0 if there are no available updates, and -1 if there were errors.''' getMachineFacts() munkicommon.report['MachineInfo'] = machine ManagedInstallDir = munkicommon....
retcode = subprocess.call(["/bin/rm" shadowfile])
retcode = subprocess.call(["/bin/rm", shadowfile])
def installWithInfo(dirpath, installlist): """ Uses the installlist to install items in the correct order. """ restartflag = False itemindex = 0 for item in installlist: if munkicommon.stopRequested(): return restartflag if "installer_item" in item: itemindex = itemindex + 1 display_name = item.get('display_name') or i...
return "0.5.2"
return "0.6.0"
def get_version(): '''Returns version of munkitools''' return "0.5.2"
payload_completed_count = 0
old_payload_completed_count = 0
def runAdobeInstallTool(cmd, number_of_payloads=0, killAdobeAIR=False): '''An abstraction of the tasks for running Adobe Setup, AdobeUberInstaller, AdobeUberUninstaller, AdobeDeploymentManager, etc''' if munkicommon.munkistatusoutput and not number_of_payloads: # indeterminate progress bar munkistatus.percent(-1) proc...
getAdobeInstallProgressInfo(payload_completed_count, payloadname) if payload_completed_count > 0:
getAdobeInstallProgressInfo(old_payload_completed_count, payloadname) if payload_completed_count > old_payload_completed_count: old_payload_completed_count = payload_completed_count
def runAdobeInstallTool(cmd, number_of_payloads=0, killAdobeAIR=False): '''An abstraction of the tasks for running Adobe Setup, AdobeUberInstaller, AdobeUberUninstaller, AdobeDeploymentManager, etc''' if munkicommon.munkistatusoutput and not number_of_payloads: # indeterminate progress bar munkistatus.percent(-1) proc...
lista = (dircache.listdir(self.thermal_path+self.i2csensors[i]+'/device'))
suffix = os.path.isdir(self.thermal_path+self.i2csensors[i]+'/device') and '/device/' or '/' lista = (dircache.listdir(self.thermal_path+self.i2csensors[i]+suffix))
def get_zones(self): if self.temp_support(): zones = [] for i in xrange(len(self.i2csensors)): lista = (dircache.listdir(self.thermal_path+self.i2csensors[i]+'/device')) for j in xrange(len(lista)): if re.search('temp[0-9]*_input', lista[j]) != None: zones.append(self.i2csensors[i]+'/device/'+lista[j]) return zones el...
zones.append(self.i2csensors[i]+'/device/'+lista[j])
zones.append(self.i2csensors[i]+suffix+lista[j])
def get_zones(self): if self.temp_support(): zones = [] for i in xrange(len(self.i2csensors)): lista = (dircache.listdir(self.thermal_path+self.i2csensors[i]+'/device')) for j in xrange(len(lista)): if re.search('temp[0-9]*_input', lista[j]) != None: zones.append(self.i2csensors[i]+'/device/'+lista[j]) return zones el...
print " $Revision: 1.10 $" print " $Date: 2010/01/26 07:07:37 $"
print " $Revision: 1.11 $" print " $Date: 2010/01/26 21:04:45 $"
def showVersion(): print print "RCS" print " $Revision: 1.10 $" print " $Date: 2010/01/26 07:07:37 $" print " $Author: noel $" print " $Source: /home/noel/active/otl2tags/RCS/otl2tags.py,v $" print
print getUnstrippedBlock(25,"|")
def main():
print " $Revision: 1.9 $" print " $Date: 2010/01/23 23:17:59 $"
print " $Revision: 1.10 $" print " $Date: 2010/01/26 07:07:37 $"
def showVersion(): print print "RCS" print " $Revision: 1.9 $" print " $Date: 2010/01/23 23:17:59 $" print " $Author: noel $" print " $Source: /home/noel/active/otl2tags/RCS/otl2tags.py,v $" print
elif (line[0] == '<'): return 'userpreftext' elif (line[0] == '|'): return 'table'
def getLineType(line): if (line[0] == ':'): return 'text' elif (line[0] == ';'): return 'preftext' elif (line[0] == '>'): return 'usertext'
def subVars(section,type,linenum,enum):
def subVars(section,type):
def subVars(section,type,linenum,enum): global config, v, parents varlist = v.keys() pattern = config.get(section,type) v["%n"] = str(linenum) v["%l"] = str(outline[linenum][1]) v["%c"] = str(enum) if len(parents) > 0: v["%p"] = str(parents[len(parents)-1]) # v["%%"] = lstrip(rstrip(lines[linePtr])) - this should be d...
v["%n"] = str(linenum) v["%l"] = str(outline[linenum][1]) v["%c"] = str(enum)
def subVars(section,type,linenum,enum): global config, v, parents varlist = v.keys() pattern = config.get(section,type) v["%n"] = str(linenum) v["%l"] = str(outline[linenum][1]) v["%c"] = str(enum) if len(parents) > 0: v["%p"] = str(parents[len(parents)-1]) # v["%%"] = lstrip(rstrip(lines[linePtr])) - this should be d...
lastline = linecount - 1 while (linenum < lastline) and (line[0] == marker):
while line[0] == marker:
def getBlock(linenum,marker): global outline, linecount lines = [] line = outline[linenum][0] lastline = linecount - 1 while (linenum < lastline) and (line[0] == marker): lines.append(stripMarker(line,marker)) linenum = linenum + 1 line = outline[linenum][0] return lines
def getUnstrippedBlock(linenum,marker): global outline, linecount lines = [] line = outline[linenum][0] while line[0] == marker: lines.append(line) linenum = linenum + 1 if linenum == linecount: break line = outline[linenum][0] return lines
def getBlock(linenum,marker): global outline, linecount lines = [] line = outline[linenum][0] lastline = linecount - 1 while (linenum < lastline) and (line[0] == marker): lines.append(stripMarker(line,marker)) linenum = linenum + 1 line = outline[linenum][0] return lines
print subVars("Headings","before-headings",linenum,enum)
print subVars("Headings","before-headings")
def handleHeading(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-headings",linenum,enum) if children: print subVars("Headings","branch-heading",linenum,enum) parents.append([linenum,enum]) handleObjects(children) paren...
print subVars("Headings","branch-heading",linenum,enum)
print subVars("Headings","branch-heading")
def handleHeading(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-headings",linenum,enum) if children: print subVars("Headings","branch-heading",linenum,enum) parents.append([linenum,enum]) handleObjects(children) paren...
print subVars("Headings","after-headings",linenum,enum)
print subVars("Headings","after-headings")
def handleHeading(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-headings",linenum,enum) if children: print subVars("Headings","branch-heading",linenum,enum) parents.append([linenum,enum]) handleObjects(children) paren...
print subVars("Headings","leaf-heading",linenum,enum)
print subVars("Headings","leaf-heading")
def handleHeading(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-headings",linenum,enum) if children: print subVars("Headings","branch-heading",linenum,enum) parents.append([linenum,enum]) handleObjects(children) paren...
print subVars("Headings","before-bulleted-headings",linenum,enum)
print subVars("Headings","before-bulleted-headings")
def handleBulleted(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-bulleted-headings",linenum,enum) if children: print subVars("Headings","branch-bulleted-heading",linenum,enum) parents.append([linenum,enum]) handleObje...
print subVars("Headings","branch-bulleted-heading",linenum,enum)
print subVars("Headings","bulleted-branch-heading")
def handleBulleted(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-bulleted-headings",linenum,enum) if children: print subVars("Headings","branch-bulleted-heading",linenum,enum) parents.append([linenum,enum]) handleObje...
print subVars("Headings","after-bulleted-headings",linenum,enum)
print subVars("Headings","after-bulleted-headings")
def handleBulleted(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-bulleted-headings",linenum,enum) if children: print subVars("Headings","branch-bulleted-heading",linenum,enum) parents.append([linenum,enum]) handleObje...
print subVars("Headings","leaf-bulleted-heading",linenum,enum)
print subVars("Headings","bulleted-leaf-heading")
def handleBulleted(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-bulleted-headings",linenum,enum) if children: print subVars("Headings","branch-bulleted-heading",linenum,enum) parents.append([linenum,enum]) handleObje...
print subVars("Headings","before-numbered-headings",linenum,enum)
print subVars("Headings","before-numbered-headings")
def handleNumbered(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-numbered-headings",linenum,enum) if children: print subVars("Headings","branch-numbered-heading",linenum,enum) parents.append([linenum,enum]) handleObje...
print subVars("Headings","branch-numbered-heading",linenum,enum)
print subVars("Headings","numbered-branch-heading")
def handleNumbered(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-numbered-headings",linenum,enum) if children: print subVars("Headings","branch-numbered-heading",linenum,enum) parents.append([linenum,enum]) handleObje...
print subVars("Headings","after-numbered-headings",linenum,enum)
print subVars("Headings","after-numbered-headings")
def handleNumbered(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-numbered-headings",linenum,enum) if children: print subVars("Headings","branch-numbered-heading",linenum,enum) parents.append([linenum,enum]) handleObje...
print subVars("Headings","leaf-numbered-heading",linenum,enum)
print subVars("Headings","numbered-leaf-heading")
def handleNumbered(linenum,enum): global outline, parents v["%%"] = outline[linenum][0] children = getChildren(linenum) if enum == 1: print subVars("Headings","before-numbered-headings",linenum,enum) if children: print subVars("Headings","branch-numbered-heading",linenum,enum) parents.append([linenum,enum]) handleObje...
if enum == 1: list = getBlock(linenum,':') print subVars("Text","before",linenum,enum) lines = "" for line in list: if line == "": lines = lines + config.get("Text","paragraph-sep") else: lines = lines + line + config.get("Text","line-sep") v["%%"] = lines print subVars("Text","text",linenum,enum), print subVars("Text"...
if enum != 1: return v["%l"] = str(outline[linenum][1]) v["%n"] = str(linenum) v["%c"] = str(enum) list = getBlock(linenum,':') print subVars("Text","before") lines = "" for line in list: if line == "": lines = lines + config.get("Text","paragraph-sep") else: lines = lines + line + config.get("Text","line-sep") v["%%"...
def handleText(linenum,enum): global outline, parents if enum == 1: # since we're working on a block, only execute once list = getBlock(linenum,':') print subVars("Text","before",linenum,enum) lines = "" for line in list: if line == "": lines = lines + config.get("Text","paragraph-sep") else: lines = lines + line + co...
print outline[linenum],enum
if enum != 1: return v["%l"] = str(outline[linenum][1]) v["%n"] = str(linenum) v["%c"] = str(enum) list = getBlock(linenum,'>') print subVars("UserText","before") lines = "" for line in list: if line == "": lines = lines + config.get("UserText","paragraph-sep") else: lines = lines + line + config.get("UserText","line-...
def handleUserText(linenum,enum): global outline, parents # just a place keeper print outline[linenum],enum
if enum == 1: list = getBlock(linenum,';') print subVars("PrefText","before",linenum,enum) lines = "" for line in list: if line == "": lines = lines + config.get("PrefText","paragraph-sep") else: lines = lines + line + config.get("PrefText","line-sep") v["%%"] = strip(lines) print subVars("PrefText","text",linenum,enum...
if enum != 1: return v["%l"] = str(outline[linenum][1]) v["%n"] = str(linenum) v["%c"] = str(enum) list = getBlock(linenum,';') print subVars("PrefText","before") lines = "" for line in list: if line == "": lines = lines + config.get("PrefText","paragraph-sep") else: lines = lines + line + config.get("PrefText","line-...
def handlePrefText(linenum,enum): global outline, parents if enum == 1: # since we're working on a block, only execute once list = getBlock(linenum,';') print subVars("PrefText","before",linenum,enum) lines = "" for line in list: if line == "": lines = lines + config.get("PrefText","paragraph-sep") else: lines = lines...
print outline[linenum],enum
if enum != 1: return v["%l"] = str(outline[linenum][1]) v["%n"] = str(linenum) v["%c"] = str(enum) list = getBlock(linenum,'<') print subVars("UserPrefText","before") lines = "" for line in list: if line == "": lines = lines + config.get("UserPrefText","paragraph-sep") else: lines = lines + line + config.get("UserPref...
def handleUserPrefText(linenum,enum): global outline, parents # just a place keeper print outline[linenum],enum
print outline[linenum],enum
if enum != 1: return v["%l"] = str(outline[linenum][1]) v["%n"] = str(linenum) v["%c"] = str(enum) list = getUnstrippedBlock(linenum,'|') print subVars("Tables","before") for row in list: handleRow(row) print subVars("Tables","after")
def handleTable(linenum,enum): global outline, parents # just a place keeper print outline[linenum],enum
print subVars("Document","preamble",0,0)
print subVars("Document","preamble")
def addPreamble(): global outline, v v["%%"] = "" print subVars("Document","preamble",0,0)
print subVars("Document","postamble",0,0)
print subVars("Document","postamble")
def addPostamble(): global outline, v v["%%"] = "" print subVars("Document","postamble",0,0)
elif obj == 'command': handleHeading(linenum,enum)
def handleObject(linenum,enum): global outline, linecount obj = getLineType(outline[linenum][0]) if obj == 'heading': handleHeading(linenum,enum) elif obj == 'bulled': handleBulleted(linenum,enum) elif obj == 'numbered': handleNumbered(linenum,enum) elif obj == 'text': handleText(linenum,enum) elif obj == 'usertext'...
print getUnstrippedBlock(25,"|")
def main():
account_box.pack_start(hbox, False, False, 5)
account_box.pack_start(hbox, False, False, 3)
def show_settings(self, widget, data=None): """The settings pane""" ################################# # Settings Window ################################# if hasattr(self, 'preferences_window'): if self.preferences_window != None: self.preferences_window.present() return True self.preferences_window = gtk.Window(gtk.WI...
display_box.pack_start(hbox, False, False, 5)
display_box.pack_start(hbox, False, False, 3)
def show_settings(self, widget, data=None): """The settings pane""" ################################# # Settings Window ################################# if hasattr(self, 'preferences_window'): if self.preferences_window != None: self.preferences_window.present() return True self.preferences_window = gtk.Window(gtk.WI...
display_box.pack_start(hbox, False, False, 2)
display_box.pack_start(hbox, False, False, 1)
def show_settings(self, widget, data=None): """The settings pane""" ################################# # Settings Window ################################# if hasattr(self, 'preferences_window'): if self.preferences_window != None: self.preferences_window.present() return True self.preferences_window = gtk.Window(gtk.WI...
catalog_box.pack_start(hbox, False, False, 5)
catalog_box.pack_start(hbox, False, False, 3)
def show_settings(self, widget, data=None): """The settings pane""" ################################# # Settings Window ################################# if hasattr(self, 'preferences_window'): if self.preferences_window != None: self.preferences_window.present() return True self.preferences_window = gtk.Window(gtk.WI...
download_box.pack_start(hbox, False, False, 5)
download_box.pack_start(hbox, False, False, 3)
def show_settings(self, widget, data=None): """The settings pane""" ################################# # Settings Window ################################# if hasattr(self, 'preferences_window'): if self.preferences_window != None: self.preferences_window.present() return True self.preferences_window = gtk.Window(gtk.WI...
trayicon_box.pack_start(hbox, False, False, 5)
trayicon_box.pack_start(hbox, False, False, 3)
def show_settings(self, widget, data=None): """The settings pane""" ################################# # Settings Window ################################# if hasattr(self, 'preferences_window'): if self.preferences_window != None: self.preferences_window.present() return True self.preferences_window = gtk.Window(gtk.WI...
system_box.pack_start(hbox, False, False, 5)
system_box.pack_start(hbox, False, False, 3)
def show_settings(self, widget, data=None): """The settings pane""" ################################# # Settings Window ################################# if hasattr(self, 'preferences_window'): if self.preferences_window != None: self.preferences_window.present() return True self.preferences_window = gtk.Window(gtk.WI...
answer = self.create_dialog_ok_or_close("Pre-Cache", "This will cache all of the artist, album, and song information (not the songs themselves) locally to make Viridian respond faster. This process can take a long time depending on the size of your catalog. Proceed?")
answer = self.create_dialog_ok_or_close("Pre-Cache", "This will cache all of the artist, album, and song information (not the songs themselves) locally to make Viridian respond faster.\n\nThis process can take a long time depending on the size of your catalog. Proceed?")
def button_pre_cache_info_clicked(self, widget=None, data=None): """Pre-cache all album and song info.""" if self.ampache_conn.is_authenticated() == False: self.create_dialog_alert("warn", "Not Authenticated", True) return False try: # check to see if this function is running if self.button_pre_cache_locked == True: pr...
answer = self.create_dialog_ok_or_close("Ampache Catalog Updated", "The Ampache catalog on the server is newer than the local cached catalog on this computer. Would you like to update the local catalog by clearing the local cache?\n\n(You can also do this at anytime by going to File -> Clear Local Cache).")
answer = self.create_dialog_ok_or_close("Ampache Catalog Updated", "The Ampache catalog on the server is newer than the locally cached catalog on this computer.\nWould you like to update the local catalog by clearing the local cache?\n\n(You can also do this at anytime by going to File -> Clear Local Cache).")
def create_catalog_updated_dialog(self): """Create a dialog to tell the user the cache has been updated.""" answer = self.create_dialog_ok_or_close("Ampache Catalog Updated", "The Ampache catalog on the server is newer than the local cached catalog on this computer. Would you like to update the local catalog by cleari...
self.current_song_label.set_markup( '<span size="13000"><b>'+song_title_html+'</b></span>' )
if len(song_title_html) > 40: self.current_song_label.set_markup('<span size="9000"><b>'+song_title_html+'</b></span>') elif len(song_title_html) > 20: self.current_song_label.set_markup('<span size="11000"><b>'+song_title_html+'</b></span>') else: self.current_song_label.set_markup('<span size="13000"><b>'+song_title_...
def __audioengine_song_changed(self, song_id): """The function that gets called when the AudioEngine changes songs.""" if song_id == None: # nothing playing self.current_song_info = None self.play_pause_image.set_from_pixbuf(self.images_pixbuf_play) self.set_tray_tooltip('Viridian') self.window.set_title("Viridian") se...
def __get_data(self, kind, offset=None): """NOT USED YET""" """ Gets all artists/albums/song and return as a list of dictionaries. Example: [ { 'artist_id' : artist_id, 'artist_name' : artist_name}, { 'artist_id' : 1, 'artist_name' : 'The Reign of Kindo'}, { ... }, ] """ if offset == None: if self.artists_num > 5000: l...
def __get_data(self, kind, offset=None): """NOT USED YET""" """ Gets all artists/albums/song and return as a list of dictionaries. Example: [ { 'artist_id' : artist_id, 'artist_name' : artist_name}, { 'artist_id' : 1, 'artist_name' : 'The Reign of Kindo'}, { ... }, ] """ if offset == None: if self.artists_num > 5000: #...
else: return root
else: try: error = root.getElementsByTagName("error")[0].childNodes[0].data print "Error! Trying to reauthenticate :: %s" % error if self.authenticate(): return self.__call_api(values) return None except: return root
def __call_api(self, values): """Takes a dictionary of values and talks to the ampache API... returning the root elemnent of the XML""" data = urllib.urlencode(values) try: # to query ampache response = urllib2.urlopen(self.xml_rpc + '?' + data) x = self.__sanatize(response.read()) dom = xml.dom.minidom.parseString(x) ...
album_disk = int(child.getElementsByTagName('disk')[0].childNodes[0].data) try:
try: album_disk = int(child.getElementsByTagName('disk')[0].childNodes[0].data) except: album_disk = 0 try:
def get_albums_by_artist(self, artist_id): """ Gets all albums by the artist_id and returns as a list of dictionaries. Example: [ { 'artist_id' : artist_id, 'artist_name' : artist_name, 'album_id' : album_id, 'album_name' : album_name, 'album_year' : album_year, 'album_tracks' : album_tracks, '...
self.__populate_artists_dict()
c = self.db_conn.cursor() c.execute("""DELETE FROM artists""") self.db_conn.commit() c.close() if self.artists_num <= 5000: print "Less than 5000 artists" self.__populate_artists_dict() else: print "More than 5000 artists" for i in range(0, self.artists_num, 5000): print "Offset = ", i self.__populate_artists_dict(i)
def get_artist_dict(self): """Returns a dictionary of all the artists populated from the database. This will check to see if the info exists locally before querying Ampache.""" if self.__table_is_empty('artists'): self.__populate_artists_dict() try: c = self.db_conn.cursor() c.execute("""SELECT artist_id, name, custom_...
def __populate_artists_dict(self):
def __populate_artists_dict(self, offset=None):
def __populate_artists_dict(self): """Populates self.artist.dict with all artists and artists id's""" values = {'action' : 'artists', 'auth' : self.auth, } data = urllib.urlencode(values) try: response = urllib2.urlopen(self.xml_rpc, data) dom = xml.dom.minidom.parseString(response.read()) except: # The data pulled f...
values = {'action' : 'artists', 'auth' : self.auth, }
if offset == None: values = {'action' : 'artists', 'auth' : self.auth, } else: values = {'action' : 'artists', 'auth' : self.auth, 'offset' : offset, }
def __populate_artists_dict(self): """Populates self.artist.dict with all artists and artists id's""" values = {'action' : 'artists', 'auth' : self.auth, } data = urllib.urlencode(values) try: response = urllib2.urlopen(self.xml_rpc, data) dom = xml.dom.minidom.parseString(response.read()) except: # The data pulled f...
return self.__populate_artists_dict()
return self.__populate_artists_dict(offset)
def __populate_artists_dict(self): """Populates self.artist.dict with all artists and artists id's""" values = {'action' : 'artists', 'auth' : self.auth, } data = urllib.urlencode(values) try: response = urllib2.urlopen(self.xml_rpc, data) dom = xml.dom.minidom.parseString(response.read()) except: # The data pulled f...
c.execute("""DELETE FROM artists""") self.db_conn.commit()
def __populate_artists_dict(self): """Populates self.artist.dict with all artists and artists id's""" values = {'action' : 'artists', 'auth' : self.auth, } data = urllib.urlencode(values) try: response = urllib2.urlopen(self.xml_rpc, data) dom = xml.dom.minidom.parseString(response.read()) except: # The data pulled f...
tree_view.connect("row-activated", self.downloads_on_activated) tree_view.connect("button_press_event", self.downloads_on_right_click)
def __init__(self, ampache_conn, audio_engine, db_session): """Constructor for the AmpacheGUI Class. Takes an AmpacheSession Object, an AudioEngine Object and a DatabaseSession Object.""" ################################# # Set Variables ################################# self.audio_engine = audio_engine self.ampache_co...
def download_song_clicked(self, widget, song_id, progres_bar=None): self.download_song_continue = True
def download_album_clicked(self, widget): """The user cliked download album.""" for song in self.song_list_store: self.download_song_clicked(widget, song[6]) def download_song_clicked(self, widget, song_id): """The user clicked download song."""
def __update_playlist_window(self): cur_playlist = self.audio_engine.get_playlist() cur_song_num = self.audio_engine.get_current_song() self.playlist_list_store.clear() i = 0 for temp_song_id in cur_playlist: cur_song = self.ampache_conn.get_playlist_song_dict(temp_song_id) cur_string = cur_song['song_title'] + ' - ' +...
if self.download_song_continue == False: print "cancelled" return False
def _reporthook(self, numblocks, blocksize, filesize, url, iter1): #print "reporthook(%s, %s, %s)" % (numblocks, blocksize, filesize) if self.download_song_continue == False: print "cancelled" return False base = os.path.basename(url).replace('%20',' ').replace('%27', "'") #XXX Should handle possible filesize=-1. try: ...
width = int(self.db_session.variable_get('window_size_width'))
width = self.db_session.variable_get('window_size_width')
def __init__(self, ampache_conn, audio_engine, db_session): """Constructor for the AmpacheGUI Class. Takes an AmpacheSession Object, an AudioEngine Object and a DatabaseSession Object.""" ################################# # Set Variables ################################# self.audio_engine = audio_engine self.ampache_co...
height = int(self.db_session.variable_get('window_size_height'))
height = self.db_session.variable_get('window_size_height')
def __init__(self, ampache_conn, audio_engine, db_session): """Constructor for the AmpacheGUI Class. Takes an AmpacheSession Object, an AudioEngine Object and a DatabaseSession Object.""" ################################# # Set Variables ################################# self.audio_engine = audio_engine self.ampache_co...
Example: __call(action="artists", filter="kindo") This function automatically adds the 'auth' variable"""
Example: __call(action="artists", filter="kindo") """
def __call(self, **kwargs): """Takes kwargs and talks to the ampach API.. returning the root element of the XML Example: __call(action="artists", filter="kindo") This function automatically adds the 'auth' variable""" values = kwargs values['auth'] = self.auth return self.__call_api(values)