Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:13.2:Update
mate-icon-theme-faenza
matefaenza-install
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File matefaenza-install of Package mate-icon-theme-faenza
#!/usr/bin/env python import os import shutil import sys from fnmatch import fnmatch from optparse import OptionParser, OptionGroup VERSION = '0.5' home = os.getcwd() icons = [] variants = ('matefaenza', 'matefaenzadark', 'matefaenzagray') class Faenza(): ''' print header ''' def header(self): print '\n faenza-install -- version %s \n' % VERSION print ' This script performs minimum rebranding and installs the' print ' faenza-icon-theme in INSTALL_DIR (sys.argv[1]). For help' print ' run the following this script with "-h" or "--help". \n' ''' populate icons list ''' def scan(self, target): for variant in variants: for root, dirs, files in os.walk(variant): for f in files: if fnmatch(f, target + '.png'): icons.append(os.path.join(root, f)) return 0 ''' delete designated file ''' def delete(self, target): try: if os.path.exists(target): os.unlink(target) else: print ' - file not found: %s' % target except Exception, errno: print errno sys.exit(1) return 0 ''' install a file ''' def rebrand(self, distribution): self.scan('start-here') self.scan('distributor-logo') if not icons: print '\n - NO icons found.. Exiting!\n' sys.exit(1) else: for icon in icons: dirname, myfile = os.path.split(icon) filename, myext = os.path.splitext(myfile) print ' - %s' % icon try: self.delete(icon) print ' + delete file: %s' % icon except Exception, errno: print errno sys.exit(1) os.chdir(dirname) os.system('ln -s %s %s' % ( filename + '-' + dist + myext, myfile)) print ' + file rebranded to: %s' % ( filename + '-' + distribution + myext ) os.chdir(home) return 0 ''' install Faenza themes on sys.argv[1] ''' def install(self, target): print ' - Installation \n' for variant in variants: fs_dir = os.path.join(target, variant) if not os.path.isdir(fs_dir): try: shutil.copytree(variant, fs_dir) print ' + theme installed: %s' % fs_dir except Exception, err: print err return 1 else: print ' + skipping (already installed): skipping' print '' return 0 ''' verify permissions for installed files and dirs ''' def verify(self, target): if os.path.isdir(target): if (os.stat(target).st_mode) == 0775: pass else: os.chmod(target, 0755) print ' + changed permissions to 0755: %s' % (target) elif os.path.isfile(target): if (os.stat(target).st_mode) == 0644: pass else: os.chmod(target, 0644) print ' + changed permissions to 0644: %s' % (target) return 0 def main(): faenza = OptionParser( usage = '%prog [OPTIONS] INSTALL_DIR', epilog = ''' A simple python script to install icon theme with branding ''') f_group = OptionGroup(faenza, 'Distribution Options: \n' + ' - opensuse, fedora, debian, frugalware, linux-mint, \n' + ' archlinux, gnome, mandriva, slackware, archlinux, \n' + ' ubuntu, mate') faenza.add_option('-v', '--version', action='store_true', dest='version', default=False, help='print version and exit to shell') faenza.add_option('-i', '--install', action='store_true', dest='install', default=False, help='install icon themes on INSTALL_DIR') faenza.add_option('-r', '--rebrand', action='store_true', dest='rebrand', default=True, help='rebrand "start-here" and "distributor-logo" (default)') faenza.add_option('--dist', action='store', dest='distribution', default='opensuse', help='set default distribution for branding') faenza.add_option_group(f_group) (option, args) = faenza.parse_args() if len(args) != 1: faenza.print_help() return 1 if option.version: print '\n faenza-install -- version %s \n' % VERSION print ' This script performs minimum rebranding and installs the' print ' faenza-icon-theme in INSTALL_DIR (sys.argv[1]). For help' print ' run the following this script with "-h" or "--help". \n' sys.exit(0) global dist dist = str(option.distribution) run = Faenza() fs = args[0] run.header() if option.rebrand: run.rebrand(dist) if option.install: if not os.path.isdir(fs): os.makedirs(fs) run.install(fs) for root, dirs, files in os.walk(fs): for d in dirs: d = os.path.join(root, d) run.verify(d) for f in files: f = os.path.join(root, f) run.verify(f) return 0 if __name__ == '__main__': try: main() except KeyboardInterrupt: pass
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor