Beispiel #1
0
def github_issues(arg=None):
    """
    Retrieve information about cmssh tickets, e.g.
    Examples:
        cmssh> tickets     # list all cmssh tickets
        cmssh> ticket 14   # get details for given ticket id
        cmssh> ticket new  # post new ticket from cmssh
        # or post it at https://github.com/vkuznet/cmssh/issues/new
    """
    if arg == 'new':
        msg = 'You can post new ticket via web interface at\n'
        msg += 'https://github.com/vkuznet/cmssh/issues/new\n'
        msg += 'otherwise it will be posted as anonymous gist ticket'
        print_info(msg)
        if not user_input('Proceed', default='N'):
            return
        email = raw_input('Your Email : ')
        if not email:
            msg = "You did your email address"
            print_error(msg)
            return
        desc = ''
        msg = 'Type your problem, attach traceback, etc. Once done print '
        msg += msg_blue('EOF') + ' and hit ' + msg_blue('Enter') + '\n'
        print msg
        while True:
            try:
                uinput = raw_input()
                if uinput.strip() == 'EOF':
                    break
                desc += uinput + '\n'
            except KeyboardInterrupt:
                break
        if not desc:
            msg = "You did not provide bug description"
            print_error(msg)
            return
        if not user_input('Send this ticket', default='N'):
            print_info('Aborting your action')
            return
        key = 'cmssh-%s' % time.strftime("%Y-%m-%d %H:%M:%S",
                                         time.gmtime(time.time()))
        files = {key: {'content': desc}}
        res = post_ticket(key, files)
        if res.has_key('html_url'):
            print_status('New gist ticket %s' % res['html_url'])
            title = 'cmssh gist %s' % res['html_url']
            if isinstance(res, dict):
                ticket = pprint.pformat(res)
            else:
                ticket = res
            to_user = base64.decodestring('dmt1em5ldEBnbWFpbC5jb20=\n')
            send_email(to_user, email, title, ticket)
    else:
        res = get_tickets(arg)
        RESMGR.assign(res)
        pprint.pprint(res)
Beispiel #2
0
def github_issues(arg=None):
    """
    Retrieve information about cmssh tickets, e.g.
    Examples:
        cmssh> tickets     # list all cmssh tickets
        cmssh> ticket 14   # get details for given ticket id
        cmssh> ticket new  # post new ticket from cmssh
        # or post it at https://github.com/vkuznet/cmssh/issues/new
    """
    if  arg == 'new':
        msg  = 'You can post new ticket via web interface at\n'
        msg += 'https://github.com/vkuznet/cmssh/issues/new\n'
        msg += 'otherwise it will be posted as anonymous gist ticket'
        print_info(msg)
        if  not user_input('Proceed', default='N'):
            return
        email = raw_input('Your Email : ')
        if  not email:
            msg = "You did your email address"
            print_error(msg)
            return
        desc  = ''
        msg   = 'Type your problem, attach traceback, etc. Once done print '
        msg  += msg_blue('EOF') + ' and hit ' + msg_blue('Enter') + '\n' 
        print msg
        while True:
            try:
                uinput = raw_input()
                if  uinput.strip() == 'EOF':
                    break
                desc += uinput + '\n'
            except KeyboardInterrupt:
                break
        if  not desc:
            msg = "You did not provide bug description"
            print_error(msg)
            return
        if  not user_input('Send this ticket', default='N'):
            print_info('Aborting your action')
            return
        key   = 'cmssh-%s' % time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time()))
        files = {key: {'content': desc}}
        res   = post_ticket(key, files)
        if  res.has_key('html_url'):
            print_status('New gist ticket %s' % res['html_url'])
            title = 'cmssh gist %s' % res['html_url']
            if  isinstance(res, dict):
                ticket = pprint.pformat(res)
            else:
                ticket = res
            to_user = base64.decodestring('dmt1em5ldEBnbWFpbC5jb20=\n')
            send_email(to_user, email, title, ticket)
    else:
        res = get_tickets(arg)
        RESMGR.assign(res)
        pprint.pprint(res)
Beispiel #3
0
def cmscrab(arg):
    """
    Execute CRAB command, help is available at
    https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideCrabFaq
    """
    msg = \
    'CRAB FAQ: https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideCrabFaq'
    print_info(msg)
    # check if release version and work area are set (should be set at cmsrel)
    rel = os.environ.get('CMSSW_VERSION', None)
    work_area = os.environ.get('CMSSW_WORKAREA', None)
    if not rel or not work_area:
        msg = 'In order to run crab command you must '
        msg += 'run ' + msg_blue('cmsrel') + ' command'
        print_error(msg)
        return
    # check existence of crab.cfg
    crab_dir = os.path.join(work_area, 'crab')
    crab_cfg = os.path.join(crab_dir, 'crab.cfg')
    if not os.path.isdir(crab_dir):
        os.makedirs(crab_dir)
    os.chdir(crab_dir)
    if not os.path.isfile(crab_cfg):
        msg = 'No crab.cfg file found in %s' % crab_dir
        print_warning(msg)
        msg = 'Would you like to create one'
        if user_input(msg, default='N'):
            with open('crab.cfg', 'w') as config:
                config.write(crabconfig())
            msg = 'Your crab.cfg has been created, please edit it '
            msg += 'appropriately and re-run crab command'
            print_info(msg)
            print "cwd:", os.getcwd()
        return
    if os.uname()[0] == 'Darwin' and arg == '-submit':
        crab_submit_remotely(rel, work_area)
        return
    cmd = 'source $CRAB_ROOT/crab.sh; crab %s' % arg
    cmsexe(cmd)
Beispiel #4
0
def cmscrab(arg):
    """
    Execute CRAB command, help is available at
    https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideCrabFaq
    """
    msg = \
    'CRAB FAQ: https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideCrabFaq'
    print_info(msg)
    # check if release version and work area are set (should be set at cmsrel)
    rel = os.environ.get('CMSSW_VERSION', None)
    work_area = os.environ.get('CMSSW_WORKAREA', None)
    if  not rel or not work_area:
        msg  = 'In order to run crab command you must '
        msg += 'run ' + msg_blue('cmsrel') + ' command'
        print_error(msg)
        return
    # check existence of crab.cfg
    crab_dir = os.path.join(work_area, 'crab')
    crab_cfg = os.path.join(crab_dir, 'crab.cfg')
    if  not os.path.isdir(crab_dir):
        os.makedirs(crab_dir)
    os.chdir(crab_dir)
    if  not os.path.isfile(crab_cfg):
        msg = 'No crab.cfg file found in %s' % crab_dir
        print_warning(msg)
        msg = 'Would you like to create one'
        if  user_input(msg, default='N'):
            with open('crab.cfg', 'w') as config:
                config.write(crabconfig())
            msg  = 'Your crab.cfg has been created, please edit it '
            msg += 'appropriately and re-run crab command'
            print_info(msg)
            print "cwd:", os.getcwd()
        return
    if  os.uname()[0] == 'Darwin' and arg == '-submit':
        crab_submit_remotely(rel, work_area)
        return
    cmd = 'source $CRAB_ROOT/crab.sh; crab %s' % arg
    cmsexe(cmd)
Beispiel #5
0
def check_release_arch(rel):
    "Check release/architecture"
    # check if given release name is installed on user system
    rel_dir = '%s/cms/cmssw/%s' % (os.environ['SCRAM_ARCH'], rel)
    if os.path.isdir(os.path.join(os.environ['VO_CMS_SW_DIR'], rel_dir)):
        return 'ok'

    output = []
    for arch, status in get_release_arch(rel):
        if not status:
            msg = '%s release is not officially supported under %s' \
                % (rel, arch)
            print_warning(msg)
        if arch != os.environ['SCRAM_ARCH']:
            msg = 'Your SCRAM_ARCH=%s, while found arch=%s' \
                % (os.environ['SCRAM_ARCH'], arch)
            print_warning(msg)
        msg = '\n%s/%s is not installed within cmssh, proceed' \
                % (rel, arch)
        if user_input(msg, default='N'):
            os.environ['SCRAM_ARCH'] = arch
            if  not os.path.isdir(\
                os.path.join(os.environ['VO_CMS_SW_DIR'], arch)):
                bootstrap(arch)
            return 'ok'
        else:
            msg = '%s/%s rejected by user' % (rel, arch)
            output.append(msg)

    if output:
        return ', '.join(output)

    osname, osarch = osparameters()
    if osname == 'osx' and osarch == 'ia32':
        return 'OSX/ia32 is not supported in CMSSW'
    return 'no match'
Beispiel #6
0
def check_release_arch(rel):
    "Check release/architecture"
    # check if given release name is installed on user system
    rel_dir = '%s/cms/cmssw/%s' % (os.environ['SCRAM_ARCH'], rel)
    if  os.path.isdir(os.path.join(os.environ['VO_CMS_SW_DIR'], rel_dir)):
        return 'ok'

    output = []
    for arch, status in get_release_arch(rel):
        if  not status:
            msg = '%s release is not officially supported under %s' \
                % (rel, arch)
            print_warning(msg)
        if  arch != os.environ['SCRAM_ARCH']:
            msg = 'Your SCRAM_ARCH=%s, while found arch=%s' \
                % (os.environ['SCRAM_ARCH'], arch)
            print_warning(msg)
        msg = '\n%s/%s is not installed within cmssh, proceed' \
                % (rel, arch)
        if  user_input(msg, default='N'):
            os.environ['SCRAM_ARCH'] = arch
            if  not os.path.isdir(\
                os.path.join(os.environ['VO_CMS_SW_DIR'], arch)):
                bootstrap(arch)
            return 'ok'
        else:
            msg = '%s/%s rejected by user' % (rel, arch)
            output.append(msg)

    if  output:
        return ', '.join(output)

    osname, osarch = osparameters()
    if  osname == 'osx' and osarch == 'ia32':
        return 'OSX/ia32 is not supported in CMSSW'
    return 'no match'