Changes in / [dff8988:29bf25a] in ammosreader
- Files:
-
- 21 added
- 29 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ammosreader/AmmosGlobalFrameHeader.py
rdff8988 r29bf25a 1 1 """I provide an AMMOS global frame header.""" 2 2 import struct 3 from ammosreader import logger 3 import logging 4 5 logging.basicConfig(filename='ammos.log', level=logging.DEBUG) 6 4 7 5 8 class AmmosGlobalFrameHeader: … … 18 21 magic_word = elements[0].hex() 19 22 20 logger.debug("Header created")21 23 if magic_word != cls.MAGIC_WORD: 22 24 return None … … 38 40 """I return a new instance of myself initialized with above parameters.""" 39 41 if magic_word != type(self).MAGIC_WORD: 40 logg er.error("Wrong magic word found")42 logging.error("Wrong magic word found") 41 43 self.magic_word = magic_word 42 44 else: -
ammosreader/PDW.py
rdff8988 r29bf25a 4 4 import math 5 5 import numpy as np 6 from ammosreader import logger 6 7 7 8 8 class PDW(): … … 24 24 :rtype: PDW 25 25 """ 26 27 logger.info("from bytes") 28 if (len(byte_string) != 32): 29 logger.error("Byte count invalid") 30 raise TypeError("Byte count invalid") 26 assert(len(byte_string) == 32) 31 27 32 28 parts = struct.unpack('<Q4s4s4s4s4s4s', byte_string) 33 34 29 nanoseconds = (parts[0]) 35 unix_time = np.datetime64('now', 'ns').astype(int)36 if nanoseconds >= unix_time:37 raise OverflowError("Timestamp invalid")38 30 time_of_arrival = np.datetime64(nanoseconds, 'ns') 39 31 … … 69 61 modulations = {0: 'Unknown', 1: 'Unmodulated', 2: 'FM', 3: 'LFM', 4: 'PSK-2', 5: 'PSK-3', 6: 'PSK-4', 70 62 7: 'PSK-m', 8: 'NLFM', 9: 'SFM', 10: 'TFM', 11: 'Pulse too short'} 71 modulation = modulations .get(int(sixth_entry_bit_string[7:12], 2), 0)63 modulation = modulations[int(sixth_entry_bit_string[7:12], 2)] 72 64 sector = int(sixth_entry_bit_string[28:32], 2) 73 65 -
ammosreader/__init__.py
rdff8988 r29bf25a 1 import logging2 import logging.config3 import os4 from pathlib import Path5 6 # change the default log path to /var/log/ammos/ammos.log when system configuration created this dir7 # with the appropriate rights8 9 log_dir = Path(os.environ.get('AMMOS_LOG_DIR', '/tmp/'))10 11 log_path = log_dir / 'ammos.log'12 13 if not log_path.exists():14 # print(log_path, "does not exist")15 try:16 # print("Trying to create logfile", str(log_path))17 log_path.touch()18 except PermissionError:19 # print("Logging to file disabled")20 conf_file = Path(__file__).parent / 'ammos_logging.conf'21 print("Conf file", conf_file)22 logging.config.fileConfig(conf_file)23 else:24 # print("Logging to", str(log_path))25 logging.basicConfig(filename=str(log_path), encoding='utf-8', level=logging.DEBUG)26 27 logger = logging.getLogger(__name__)28 29 logger.warning("Text")
Note:
See TracChangeset
for help on using the changeset viewer.