Ejemplo n.º 1
0
def extend_django_record_with_gams_metadata(record):
    """Reads meta data from GAMS listing and ammends the sumatra record with it."""
    record.solver = 'unknown'
    record.solver_version = 'unknown'
    sumatra_record = record.to_sumatra()
    listing_data_key = sumatra_record.output_data[0]
    listing = sumatra_record.datastore.get_data_item(listing_data_key).content.decode('utf-8')
    for line in listing.splitlines():
        if line.strip().startswith('SOLVER '):
            record.solver = [word for word in line.split(' ') if word][1]
    if record.solver != 'unknown':
        for line in listing.splitlines():
            if record.solver.lower() in line.lower() and 'version' in line.lower():
                record.solver_version = version_in_command_line_output(line)
    if record.solver.lower() == 'cplex':
        for line in listing.splitlines():
            if line.lower().startswith('cplex') and len(line.split(' ')) == 2:
                record.solver_version = line.split(' ')[1]
    elif record.solver.lower() == 'conopt':
        for line in listing.splitlines():
            if record.solver.lower() in line.lower().replace(' ', '') and 'version' in line.lower():
                record.solver_version = line.split('version')[-1].strip()
    elif record.solver.lower() == 'xpress':
        for line in listing.splitlines():
            if line.startswith('Xpress-Optimizer'):
                record.solver_version = [word for word in line.split(' ') if word.startswith('v')][0][1:]
    return record
Ejemplo n.º 2
0
 def test_common_cases(self):
     examples = {
         "NEURON -- Release 7.1 (359:7f113b76a94b) 2009-10-26":
         "7.1",
         "NEST version 1.9.8498, built on Mar  2 2010 09:40:15 for x86_64-unknown-linux-gnu\nCopyright (C) 1995-2008 The NEST Initiative":
         "1.9.8498",
         "Python 2.6.2":
         "2.6.2",
         "abcdefg":
         "unknown",
         "usage: ls [-ABCFGHLPRSTWabcdefghiklmnopqrstuwx1] [file ...]":
         "unknown",
         "4.2rc3":
         "4.2rc3",
         "R scripting front-end version 3.1.2 (2014-10-31)":
         "3.1.2",
         "First version that reads numbers from 0..1":
         "unknown",
         "Mature Tool 12.10":
         "12.10",
         "Beta Tool 0.9.0.dev":
         "0.9.0.dev",
         "Another Tool 0.8.4.Clumsy message.":
         "0.8.4"
     }
     for input, output in examples.items():
         self.assertEqual(version_in_command_line_output(input), output)
Ejemplo n.º 3
0
 def test_common_cases(self):
     examples = {
         "NEURON -- Release 7.1 (359:7f113b76a94b) 2009-10-26": "7.1",
         "NEST version 1.9.8498, built on Mar  2 2010 09:40:15 for x86_64-unknown-linux-gnu\nCopyright (C) 1995-2008 The NEST Initiative": "1.9.8498",
         "Python 2.6.2": "2.6.2",
         "abcdefg": "unknown",
         "usage: ls [-ABCFGHLPRSTWabcdefghiklmnopqrstuwx1] [file ...]": "unknown",
         "4.2rc3": "4.2rc3",
         "R scripting front-end version 3.1.2 (2014-10-31)": "3.1.2",
         "First version that reads numbers from 0..1": "unknown",
         "Mature Tool 12.10": "12.10",
         "Beta Tool 0.9.0.dev": "0.9.0.dev",
         "Another Tool 0.8.4.Clumsy message.": "0.8.4"
     }
     for input, output in examples.items():
         self.assertEqual(version_in_command_line_output(input), output)
Ejemplo n.º 4
0
 def _get_version(self):
     returncode, output, err = run("gams file_that_doesnt_exist.gms lo=3", shell=True)
     return version_in_command_line_output(command_line_output=output + err)