def test_shutdown_with_boot(self):

        with open(self.input_file, 'w') as inputfile:
            inputfile.write('1970-01-01 # 00.01 # shutdown # 1 # 1\n' +
                            '2013-04-05 # 13.39 # boot # 42 # 612\n')

        self.logmodule = SimplePhoneLogsMemacs(argv = self.argv.split())
        self.logmodule.handle_main()

        result = self.get_result_from_file()

        self.assertEqual(result, """** <1970-01-01 Thu 00:01> shutdown
   :PROPERTIES:
   :IN-BETWEEN:
   :IN-BETWEEN-S:
   :BATT-LEVEL:   1
   :UPTIME:       0:00:01
   :UPTIME-S:     1
   :ID:           ef7327b6c8f6e9de6ae6271d601f96133cd5b524
   :END:

** <2013-04-05 Fri 13:39> boot (off for 15800d 13:38:00)
   :PROPERTIES:
   :IN-BETWEEN:   379213:38:00
   :IN-BETWEEN-S: 1365169080
   :BATT-LEVEL:   42
   :UPTIME:       0:10:12
   :UPTIME-S:     612
   :ID:           ff09a7043203c0d9eeb116779789dc19a992e299
   :END:""")
Beispiel #2
0
    def test_shutdown_with_boot(self):

        with open(self.input_file, 'w') as inputfile:
            inputfile.write('1970-01-01 # 00.01 # shutdown # 1 # 1\n' +
                            '2013-04-05 # 13.39 # boot # 42 # 612\n')

        self.logmodule = SimplePhoneLogsMemacs(argv = self.argv.split())
        self.logmodule.handle_main()

        result = self.get_result_from_file()

        self.assertEqual(result, u"""** <1970-01-01 Thu 00:01> shutdown
   :PROPERTIES:
   :IN-BETWEEN:
   :BATT-LEVEL:   1
   :UPTIME:       0:00:01
   :UPTIME-S:     1
   :IN-BETWEEN-S:
   :ID:           908b94cc00a0981c811f8392b85d4b5603476907
   :END:

** <2013-04-05 Fri 13:39> boot (off for 15800d 13:38:00)
   :PROPERTIES:
   :IN-BETWEEN:   379213:38:00
   :BATT-LEVEL:   42
   :UPTIME:       0:10:12
   :UPTIME-S:     612
   :IN-BETWEEN-S: 1365169080
   :ID:           0602b98ba31416e5ae7e2964455de121c7492a70
   :END:""")
Beispiel #3
0
    def test_parser(self):

        result_file = os.path.dirname(os.path.abspath(
            __file__)) + os.path.sep + "sample-phonelog-result-TEMP.org"

        argv = "-f " + self.test_file + \
            " --output " + result_file

        localmodule = SimplePhoneLogsMemacs(argv=argv.split())
        localmodule.handle_main()

        result_from_module = CommonReader.get_data_from_file(result_file)

        result_from_module_without_header_and_last_line = u''
        for line in result_from_module.split('\n'):
            if line.startswith(u'* successfully parsed ') or \
                    line.startswith(u'#') or \
                    line.startswith(u'* '):
                pass
            else:
                result_from_module_without_header_and_last_line += line + '\n'

        ## self.reference_result is defined below!
        self.assertEqual(result_from_module_without_header_and_last_line,
                         self.reference_result)

        os.remove(result_file)
 def setUp(self):
     super(TestSimplePhoneLogsFull, self).setUp()
     self.test_file = os.path.join(
         os.path.dirname(os.path.abspath(__file__)), 'data',
         'sample-phonelog.csv')
     self.argv = "-s -f " + self.test_file + " --output " + self.result_file
     self.logmodule = SimplePhoneLogsMemacs(argv=self.argv.split())
     self.logmodule.handle_main()
Beispiel #5
0
    def test_parser(self):

        argv = "-f " + self.test_file + \
            " --output " + self.result_file

        localmodule = SimplePhoneLogsMemacs(argv = argv.split())
        localmodule.handle_main()

        result = self.get_result_from_file()
        self.assertEqual(result, self.reference_result)
Beispiel #6
0
def main():
    global memacs
    memacs = SimplePhoneLogsMemacs(
        prog_version=PROG_VERSION_NUMBER,
        prog_version_date=PROG_VERSION_DATE,
        prog_description=PROG_DESCRIPTION,
        prog_short_description=PROG_SHORT_DESCRIPTION,
        prog_tag=PROG_TAG,
        copyright_year=COPYRIGHT_YEAR,
        copyright_authors=COPYRIGHT_AUTHORS)
    memacs.handle_main()
Beispiel #7
0
    def setUp(self):

        result_file = os.path.dirname(os.path.abspath(
            __file__)) + os.path.sep + "sample-phonelog-result-TEMP.org"

        self.test_file = os.path.dirname(
            os.path.abspath(__file__)) + os.sep + "tmp" \
            + os.path.sep + "sample-phonelog.csv"

        self.argv = "-s -f " + self.test_file + " --output " + result_file

        self.logmodule = SimplePhoneLogsMemacs(argv=self.argv.split())
        self.logmodule.handle_main()
Beispiel #8
0
    def test_boot_without_shutdown(self):

        with open(self.input_file, 'w') as inputfile:
            inputfile.write('2013-04-05 # 13.39 # boot # 42 # 612\n')

        self.logmodule = SimplePhoneLogsMemacs(argv = self.argv.split())
        self.logmodule.handle_main()

        result = self.get_result_from_file()

        self.assertEqual(result, u"""** <2013-04-05 Fri 13:39> boot
   :PROPERTIES:
   :IN-BETWEEN:
   :BATT-LEVEL:   42
   :UPTIME:       0:10:12
   :UPTIME-S:     612
   :IN-BETWEEN-S:
   :ID:           50f3642555b86335789cc0850ee02652765b30a8
   :END:""")
    def test_boot_without_shutdown(self):

        with open(self.input_file, 'w') as inputfile:
            inputfile.write('2013-04-05 # 13.39 # boot # 42 # 612\n')

        self.logmodule = SimplePhoneLogsMemacs(argv = self.argv.split())
        self.logmodule.handle_main()

        result = self.get_result_from_file()

        self.assertEqual(result, """** <2013-04-05 Fri 13:39> boot
   :PROPERTIES:
   :IN-BETWEEN:
   :IN-BETWEEN-S:
   :BATT-LEVEL:   42
   :UPTIME:       0:10:12
   :UPTIME-S:     612
   :ID:           0d78f4b2834126ecfc3fcf9cd45e5a077d055f0c
   :END:""")
Beispiel #10
0
    def test_crashrecognition(self):


        with open(self.input_file, 'w') as inputfile:
            inputfile.write('2013-04-05 # 13.25 # shutdown # 1 # 10\n' +
                            '2013-04-05 # 13.30 # boot # 2 # 11\n' +
                            '2013-04-05 # 13.39 # boot # 3 # 12\n')

        self.logmodule = SimplePhoneLogsMemacs(argv = self.argv.split())
        self.logmodule.handle_main()

        result = self.get_result_from_file()

        self.assertEqual(result, u"""** <2013-04-05 Fri 13:25> shutdown
   :PROPERTIES:
   :IN-BETWEEN:
   :BATT-LEVEL:   1
   :UPTIME:       0:00:10
   :UPTIME-S:     10
   :IN-BETWEEN-S:
   :ID:           0ec0d92a33e4476756659fe6ca0ab78fc470747c
   :END:

** <2013-04-05 Fri 13:30> boot (off for 0:05:00)
   :PROPERTIES:
   :IN-BETWEEN:   0:05:00
   :BATT-LEVEL:   2
   :UPTIME:       0:00:11
   :UPTIME-S:     11
   :IN-BETWEEN-S: 300
   :ID:           5af2d989502a85deefc296936e9bf59087ecec2b
   :END:

** <2013-04-05 Fri 13:39> boot after crash
   :PROPERTIES:
   :IN-BETWEEN:
   :BATT-LEVEL:   3
   :UPTIME:       0:00:12
   :UPTIME-S:     12
   :IN-BETWEEN-S:
   :ID:           00903218ae1c5d02f79f9d527c5767dce580f10f
   :END:""")
Beispiel #11
0
    def test_crashrecognition(self):


        with open(self.input_file, 'w') as inputfile:
            inputfile.write('2013-04-05 # 13.25 # shutdown # 1 # 10\n' +
                            '2013-04-05 # 13.30 # boot # 2 # 11\n' +
                            '2013-04-05 # 13.39 # boot # 3 # 12\n')

        self.logmodule = SimplePhoneLogsMemacs(argv = self.argv.split())
        self.logmodule.handle_main()

        result = self.get_result_from_file()

        self.assertEqual(result, """** <2013-04-05 Fri 13:25> shutdown
   :PROPERTIES:
   :IN-BETWEEN:
   :IN-BETWEEN-S:
   :BATT-LEVEL:   1
   :UPTIME:       0:00:10
   :UPTIME-S:     10
   :ID:           5a5fd30fcf0bb105d3fcbf3471d343adb8a1c57d
   :END:

** <2013-04-05 Fri 13:30> boot (off for 0:05:00)
   :PROPERTIES:
   :IN-BETWEEN:   0:05:00
   :IN-BETWEEN-S: 300
   :BATT-LEVEL:   2
   :UPTIME:       0:00:11
   :UPTIME-S:     11
   :ID:           e70436685735120f1e468e1ea155cc370b6d69ad
   :END:

** <2013-04-05 Fri 13:39> boot after crash
   :PROPERTIES:
   :IN-BETWEEN:
   :IN-BETWEEN-S:
   :BATT-LEVEL:   3
   :UPTIME:       0:00:12
   :UPTIME-S:     12
   :ID:           dc41b7d0b6b415ff3a3335c1a4ad0e5ce36f5152
   :END:""")