Exemplo n.º 1
0
def main():
    load('bookshelf.conf')
    if config('LOCALE') is not None and config('LOCALE') != '':
        Locale.setDefault(Locale(config('LOCALE')))
    from window import BookshelfView
    from logic import Bookshelf
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
    view = BookshelfView(Bookshelf())
    screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    view.setLocation(screenSize.width/5,  screenSize.height/5)
    view.setVisible(1)
Exemplo n.º 2
0
def get_pdbredo_data(pdbids=[]):
    global CACHE_EXPIRED
    alldatapath = os.path.join(PDBfiles.CACHEDIR, os.path.basename(ALLDATA_URL))
    # if not os.path.isfile(alldatapath): #Download
    tries = 3
    dateformat = " on %a, %d %b %Y %H:%M:%S "
    while tries > 0:
        tries -= 1
        if sys.platform.startswith("java"):
            oldlocale = Locale.getDefault()
            Locale.setDefault(Locale.ENGLISH)
        try:
            download = False
            olddate = datetime.datetime(1, 1, 1)
            if os.path.isfile(alldatapath):
                alldata = open(alldatapath, "r")
                for line in alldata:
                    if "Created on" in line:
                        olddate = datetime.datetime.strptime(line.split("+")[0].split("Created")[1], dateformat)
                        break
                alldata.close()
            rfh = urllib2.urlopen(ALLDATA_URL)
            firstlines = ""
            for line in rfh:
                if download:
                    alldata.write(line)
                    continue
                firstlines += line
                if not download and "Created on" in line:
                    newdate = datetime.datetime.strptime(line.split("+")[0].split("Created")[1], dateformat)
                    if newdate <= olddate:
                        print "%s is up to date (%s)" % (alldatapath, olddate.__str__())
                        CACHE_EXPIRED = False
                        break
                    else:
                        CACHE_EXPIRED = True
                        download = True
                        alldata = open(alldatapath, "w")
                        alldata.write(firstlines)
                        print "Downloading %s" % ALLDATA_URL
            # alldata.write(rfh.read())
            alldata.close()
            rfh.close()
            break
        except Exception, e:
            print "Could not download", ALLDATA_URL
            print e
            print "Retrying...", tries
            time.sleep(1)
        if sys.platform.startswith("java"):
            Locale.setDefault(oldlocale)
Exemplo n.º 3
0
        isTemporal = True
    else:
        isDominant = True
        isTemporal = False
else:
    isDominant = False
    isTemporal = False
lpath = None
if isTemporal:
    myPath = ".lositemp"
elif isDominant:
    myPath = ".mcheza"
else:
    myPath = ".lositan"
for path in sys.path:
    if path.find(myPath) > -1 and path.find("jar") == -1 and \
            path.find("libs") == -1:
        lpath = path
if not lpath: #local mode
    for path in sys.path:
        if path.find('scratch') > -1 and path.find("jar") == -1 and \
                path.find("libs") == -1:
            lpath = path
Locale.setDefault(Locale.US)
openDir()
prepareFDist()
styleApp()
frame = createFrame()
dataPath = None
disablePanel(empiricalPanel, ["theta", "beta1", "beta2", "crit"])
Exemplo n.º 4
0
def aozan_main():
    """Aozan main method.
    """

    # Define command line parser
    parser = OptionParser(usage='usage: ' + Globals.APP_NAME_LOWER_CASE + '.sh [options] conf_file')
    parser.add_option('-q', '--quiet', action='store_true', dest='quiet',
                      default=False, help='quiet')
    parser.add_option('-v', '--version', action='store_true', dest='version', help='Aozan version')
    parser.add_option('-e', '--exit-code', action='store_true', dest='exit_code',
                      help='Returns non zero exit code if a step fails')
    parser.add_option('-c', '--conf', action='store_true', dest='conf',
                      help='Default Aozan configuration, loads before configuration file.')

    # Parse command line arguments
    (options, args) = parser.parse_args()

    # Print Aozan current version
    if options.version:
        print Globals.WELCOME_MSG
        sys.exit(0)

    #  Print default configuration option
    if options.conf:
        print common.print_default_configuration()
        sys.exit(0)

    # If no argument print usage
    if len(args) < 1:
        parser.print_help()
        sys.exit(1)

    # Create configuration object
    conf = LinkedHashMap()

    # Set the default value in the configuration object
    common.set_default_conf(conf)

    # Use default (US) locale
    Locale.setDefault(Globals.DEFAULT_LOCALE)

    # Check if OS is Linux
    if not SystemUtils.isLinux():
        sys.stderr.write('ERROR: Aozan can not be executed. Operating system is not Linux\n')
        sys.exit(1)

    # Check if configuration file exists
    conf_file = args[0]
    if not os.path.isfile(conf_file):
        sys.stderr.write('ERROR: Aozan can not be executed. Configuration file is missing: ' + \
                         conf_file + '\n')
        sys.exit(1)

    # Load Aozan conf file
    common.load_conf(conf, conf_file)

    # End of Aozan if aozan is not enable
    if common.is_conf_value_defined(AOZAN_ENABLE_KEY, 'false', conf):
        sys.exit(0)

    # Init logger
    try:
        Common.initLogger(conf[AOZAN_LOG_PATH_KEY], conf[AOZAN_LOG_LEVEL_KEY])
    except AozanException, exp:
        common.exception_msg(exp, conf)