Example #1
0
 def tearDownClass(cls):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "-c", "test/configs/restore_default_config.cfg",
                 "-c", "configs/restore_default_config.cfg", ]
     DipplannerCliArguments(cli_args)
Example #2
0
def main(cli_arguments=None):
    """Main entry point.

    main uses the parameters, tanks and dives given in config file(s)
    and/or command line, calculates the dives and return the output in stdout.

    :param list cli_arguments: list of arguments, like sys.argv
    """
    if sys.version_info < (3, 4):
        raise SystemExit("ERROR: This programm needs python 3.4 or greater")

    if cli_arguments is None:
        cli_arguments = sys.argv

    activate_debug()

    # get the version
    try:
        version_file = open("RELEASE-VERSION", "r")
        try:
            version = version_file.readlines()[0]
            settings.__VERSION__ = version.strip()
        finally:
            version_file.close()
    except IOError:
        settings.__VERSION__ = "unknown"

    dipplanner_arguments = DipplannerCliArguments(cli_arguments)
    dives = dipplanner_arguments.dives

    profiles = []
    current_dive = None
    previous_dive = None
    for dive in dives:
        if previous_dive is None:
            current_dive = Dive(dives[dive]['segments'].values(),
                                dives[dive]['tanks'].values())
        else:
            current_dive = Dive(dives[dive]['segments'].values(),
                                dives[dive]['tanks'].values(), previous_dive)
        if dives[dive]['surface_interval']:
            current_dive.do_surface_interval(dives[dive]['surface_interval'])

        current_dive.do_dive_without_exceptions()
        profiles.append(current_dive)
        previous_dive = current_dive
        # now, dive exceptins do not stop the program anymore, but can be
        # displayed in the output template instead. The used MUST take care of
        # the result.

    # now calculate no flight time based on the last dive
    ######current_dive.no_flight_time_wo_exception()

    # now Prepare the output
    env = Environment(loader=PackageLoader('dipplanner', 'templates'))
    tpl = env.get_template(settings.TEMPLATE)
    # pylint: disable=no-member
    text = tpl.render(settings=settings, dives=profiles)
    # pylint: enable=no-member
    print(text)
Example #3
0
 def test_gflow(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--gflow=22%", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.GF_LOW, 0.22,
                      "Wrong gllow: %s" % settings.GF_LOW)
Example #4
0
 def test_deco_model(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--model=ZHL16b", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.DECO_MODEL, 'ZHL16b',
                      "Wrong model: %s" % settings.DECO_MODEL)
Example #5
0
 def test_gfhigh(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--gfhigh=95", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.GF_HIGH, 0.95,
                      "Wrong gfhigh: %s" % settings.GF_HIGH)
Example #6
0
 def test_ascentrate(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--ascentrate=9", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.ASCENT_RATE,
                      9.0 / 60,
                      "Wrong ascentrate: %s" % settings.ASCENT_RATE)
Example #7
0
 def test_water(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--water=fresh", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.WATER_DENSITY,
                      settings.FRESH_WATER_DENSITY,
                      "Wrong water type: %s" % settings.WATER_DENSITY)
Example #8
0
 def test_travelswitch(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--travelswitch=early", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.TRAVEL_SWITCH,
                      'early',
                      "Wrong travelswitch: %s" %
                      settings.TRAVEL_SWITCH)
Example #9
0
 def test_surfaceinterval(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--surfaceinterval=200", ]
     dipplanner_arguments = DipplannerCliArguments(cli_args)
     dives = dipplanner_arguments.dives
     args = dipplanner_arguments.args
     self.assertEqual(dives['diveCLI']['surface_interval'], 200,
                      "Wrong surface interval: %s" % args.surfaceinterval)
Example #10
0
 def test_template(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--template=default.html", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.TEMPLATE,
                      'default.html',
                      "Wrong template: %s" %
                      settings.TEMPLATE)
Example #11
0
 def test_ambiantpressureatsea(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--ambiantpressureatsea=1.01", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.AMBIANT_PRESSURE_SEA_LEVEL,
                      1.01,
                      "Wrong ambiantpressureatsea: %s" %
                      settings.AMBIANT_PRESSURE_SEA_LEVEL)
Example #12
0
 def test_decoconsrate(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--decoconsrate=21", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.DECO_CONSUMPTION_RATE,
                      21.0/60,
                      "Wrong decoconsrate: %s" %
                      settings.DECO_CONSUMPTION_RATE)
Example #13
0
 def test_depthcalcmethod(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--depthcalcmethod=simple", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.METHOD_FOR_DEPTH_CALCULATION,
                      'simple',
                      "Wrong depthcalcmethod: %s" %
                      settings.METHOD_FOR_DEPTH_CALCULATION)
Example #14
0
 def test_forcesegmenttime(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--forcesegmenttime", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.RUN_TIME,
                      False,
                      "Wrong forcesegmenttime: %s" %
                      settings.RUN_TIME)
Example #15
0
 def test_samegasdeco(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--samegasfordeco", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.USE_OC_DECO,
                      False,
                      "Wrong samegasfordeco: %s" %
                      settings.USE_OC_DECO)
Example #16
0
 def test_maxend(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--maxend=33", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.DEFAULT_MAX_END,
                      33,
                      "Wrong maxend: %s" %
                      settings.DEFAULT_MAX_END)
Example #17
0
 def test_minppo2(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--minppo2=0.17", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.DEFAULT_MIN_PPO2,
                      0.17,
                      "Wrong minppo2: %s" %
                      settings.DEFAULT_MIN_PPO2)
Example #18
0
 def test_mawppo2(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--maxppo2=1.5", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.DEFAULT_MAX_PPO2,
                      1.5,
                      "Wrong mawppo2: %s" %
                      settings.DEFAULT_MAX_PPO2)
Example #19
0
 def test_altitude(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--altitude=2456", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.AMBIANT_PRESSURE_SURFACE,
                      altitude_to_pressure(2456),
                      "Wrong altitude pressure: %s" %
                      settings.AMBIANT_PRESSURE_SURFACE)
Example #20
0
 def test_surfacetemp_2(self):
     cli_args = ["dipplanner",
                 "-t", "airtank;0.21;0.0;12;200;50b",
                 "-s", "30;25*60;airtank;0.0",
                 "--surfacetemp=29", ]
     _ = DipplannerCliArguments(cli_args)
     self.assertEqual(settings.SURFACE_TEMP,
                      29,
                      "Wrong surfacetemp: %s" %
                      settings.SURFACE_TEMP)
Example #21
0
    def setUp(self):
        TestCliArguments.setUp(self)
        cli_args = ["dipplanner",
                    "-t", "airtank;0.21;0.0;12;200;50b",
                    "-s", "30;25*60;airtank;0.0",
                    "-c", "dipplanner/tests/configs/test_config.cfg",
                    "-c", "configs/test_config.cfg", ]

        dipplanner_arguments = DipplannerCliArguments(cli_args)
        self.dives = dipplanner_arguments.dives
        self.args = dipplanner_arguments.args