예제 #1
0
파일: install.py 프로젝트: emulbreh/ecs
 def install_postconfig(postconfigdata):
     ''' run a postconfig string, internal '''
     postconfig= 'PYTHONENV=%s; PYTHONVER=%s; FABDIR=%s; '+postconfigdata
     pythonver = '%d.%d' % sys.version_info[:2]
     postconfig= postconfig % (get_pythonenv(), pythonver, fabdir())
     result= local(postconfig, capture=False)
     _abort_failed(result)
예제 #2
0
파일: base.py 프로젝트: emulbreh/ecs
    def install_packages(self, packages, upgrade=False):
        upgradeoption = ""
        if upgrade: upgradeoption= "--upgrade"
        
        for packageline in self.get_packages(packages):
            (name, pkgtype, platform, resource, url, opt1, opt2) = packageline_split(packageline)
            if resource in ["pypi"]:
                pass
            elif resource in ["http", "https", "ftp"]:
                url = "".join((resource,":",url))
            elif resource in ["file", "dir"]:
                url = os.path.join(fabdir(), url)
            else:
                abort("unimplemented resource %s" % (resource))        

            # try to take package from the fridge (externals/frozen)
            resource, url = try_frozen(resource,url)
            
            if pkgtype == "inst":
                print("Information: installing %s from %s on matching platform %s" % (name, resource, platform))
                if resource in ["pypi", "http", "https", "ftp"]:        
                    with settings(warn_only=True):
                        if resource == "pypi":
                            if sys.platform == "win32":
                                url=url.replace('\\','^')
                            else:
                                url="".join(('"',url,'"'))
                                url=url.replace('\\','')
                        result=local('pip install --no-deps %s %s' % (upgradeoption, url))
                elif resource in ["file", "dir"]:
                    with settings(warn_only=True):
                        result=local('%s --always-copy --always-unzip --no-deps %s' % (self.easy_install, url))
                else:
                    abort("unimplemented resource %s" % (resource))
                _abort_failed(result)
                
            elif pkgtype == "instbin":
                if resource in ["http", "https", "ftp", "file"]:    
                    with settings(warn_only=True):
                        result=local('%s --always-copy --always-unzip --no-deps %s' % (self.easy_install, url))                    
                    _abort_failed(result)
                else:
                    abort("unimplemented resource %s" % (resource))

            else:
                warn("unimplemented package type %s in line: %s" % (pkgtype, packageline))
예제 #3
0
파일: fridge.py 프로젝트: emulbreh/ecs
def fridge_refill(appname, flavor="default", refill_behavior= RB_IGNORE):
    '''
    refill fridge: appname, flavor, refill_behavior
    
    refill_behavior= 
    "abort-if-existing" abort if file to be downloaded already exists
    "ignore-if-existing" ignore file to be downloaded if already exists 
    "update-if-different" update file if file to be downloaded is unequal stored file 
    "overwrite-existing" download file and overwrite regardless if already there and equal 
    '''
    if refill_behavior not in REFILL_BEHAVIOR:
        abort("refill behavior can be only one of %s" % str(REFILL_BEHAVIOR))
    
    if not os.path.exists(_fridgedir()):
        os.makedirs(_fridgedir())

    appconfigfile = os.path.join(fabdir(), appname, 'application.py')
    appconfig = import_from(appconfigfile)
    try:
        package_bundles = appconfig.package_bundles
    except AttributeError:
        abort('package_bundles is not defined')  
    try:
        package_bundle = package_bundles[flavor]
    except KeyError:
        abort('No flavor "%s"\n' % flavor)
    
    package_bundle= package_merge(package_bundle)
   
    for line in package_bundle.splitlines():       
        (name, pkgtype, platform, resource, url, opt1, opt2) = packageline_split(line)
        if name is None:
            continue
        if resource not in ['https', 'http', 'ftp', 'pypi']:
            continue
        if resource == "pypi":
            url = url.replace('\\','')
        elif resource in ["http", "https", "ftp"]:
            url = "".join((resource,":",url))

        print "freezing ", name, pkgtype, platform, resource, url, opt1, opt2, " as ", _frozenname(resource, url)
        _transfer_to_fridge(resource, url, refill_behavior)
예제 #4
0
파일: fridge.py 프로젝트: emulbreh/ecs
def _fridgedir():
    return os.path.join(fabdir(), FRIDGE_PLACE)
예제 #5
0
def ticket(command=None, resource=None, value=None, comment=None, verbose=False):
    ''' update a ticket via cmdline, see fab ticket:help
    
usage: fab ticket:command [,resource [,value [,comment [,verbose]]]]
    
commands:
 * <empty>|my          # "fab ticket" show all tickets where you are the owner
 * get|show,ticketid   # "fab ticket:show,123" shows ticket 123 
 * ed[it],ticketid     # "fab ticket:ed,123" edits ticket 123

 * eta|rt|remain,ticketid,3  
   # "fab ticket:eta,123,3" set the remaining time(estimated arival) to 3 hours
 
 * ack|accept,ticketid   
   # eg. fab ticket:ack,123 accepts ticket 123, which sets owner to user
   
 * cl[ose],ticketid[,fixed|invalid|wontfix|duplicate|worksforme]
   # User Stories & Bugs are set to 'testing' automagically,
   # override with resolution='fixed|invalid|wontfix|duplicate|worksforme'
   # default resolution for everything else is fixed
   # "fab ticket:cl,123,invalid" closes ticket 123, sets resolution to invalid
   
 * rop|reopen,ticketid  # "fab ticket:rop,123" reopen ticket 123 if possible
 
resource, value, comment, verbose can be used via named variables, 
    eg. "fab ticket:eta,23,3,verbose=True"
    '''
    import sys, os
    
    from fabric.utils import abort
    from deployment.utils import get_homedir, fabdir, import_from
    from deployment.utils import strbool as _strb
    
    from auth import ADAauth
    
    # FIXME it seems without a PYTHON_PATH set we cant import from ecs...
    sys.path.append(fabdir())
    from ecs.utils import tracrpc

    if command in ['help']:
        print(ticket.__doc__)
        return
    
    verbose = _strb(verbose)
    tracauth = ADAauth()
    tracauth.search_paths.append(get_homedir())
    tracauth.search_paths.append(os.path.join(fabdir(), ".hg"))
    tracauth.get_credentials()
    bot = tracrpc.TracRpc(tracauth.credentials[0]['username'], tracauth.credentials[0]['password'], "https", "ecsdev.ep3.at", "/project/ecs")
    
    if command in [None, 'my']:
        bot.show_ticket_report(tracauth.credentials[0]['username'], verbose)
    elif command in ['get', 'show']:
        bot.show_ticket(int(resource), verbose)
    elif command in ['ed', 'edit']:
        bot.edit_ticket(int(resource), comment)
    elif command in ['eta', 'rt', 'remain']:
        bot.update_remaining_time(int(resource), value, comment)
    elif command in ['ack', 'accept']:
        bot.accept_ticket(int(resource), comment)
    elif command in ['cl', 'close']:
        bot.close_ticket(int(resource), resolution=value, comment=comment)
    elif command in ['rop', 'reopen']:
        bot.reopen_ticket(int(resource), comment=comment)
    elif command in ['act', 'actions']:
        bot.show_actions(int(resource), verbose)
    elif command in ['crt', 'create']:
        bot.create_ticket(verbose=verbose)
    elif command in ['feedbackreport', 'fbr']:
        query_base = "order=id&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component"
        query = query_base + "&type=idea&type=question&type=problem&type=praise"
        bot.show_ticket_report(query=query, verbose=verbose)
    elif command in ['deletefeedbackreport']:
        return
        
        #THIS is only for cleanup before the sprint release
        #actual delete has to be commented in in tracrpc
        from fabric.contrib import console
        from time import sleep
        query_base = "order=id&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component"
        query = query_base + "&type=idea&type=question&type=problem&type=praise"
        
        bot.show_ticket_report(query=query, verbose=verbose)
        question = "Do you really want to delete all these tickets?"
        if console.confirm(question, default=False):
            allowed = False
            allowed,query = bot.delete_tickets_by_query(query=query, verbose=verbose)
            if allowed:
                print "Are you really really sure?"
                print "THINK...!"
                sleep(15)
                question = "Still sure?"
                if console.confirm(question, default=False):
                    bot.delete_tickets_by_query(query=query, verbose=verbose, doublecheck=allowed)
                    
    elif command in ['query', 'q']:
        bot.show_ticket_report(query=resource, verbose=verbose)
    else:
        abort("unknown command %s, see fab ticket:help for help" % command)