Changeset b00fbbb in ammosreader
- Timestamp:
- 05/19/23 12:33:29 (2 years ago)
- Branches:
- AmmosSource, guix
- Children:
- efb5900
- Parents:
- dff8988
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ammosreader/__init__.py
rdff8988 rb00fbbb 4 4 from pathlib import Path 5 5 6 # change the default log path to /var/log/ammos/ammos.log when system configuration created this dir6 # FIXME: change the default log path to /var/log/ammos/ammos.log when system configuration created this dir 7 7 # with the appropriate rights 8 8 … … 12 12 13 13 if not log_path.exists(): 14 # print(log_path, "does not exist")15 14 try: 16 # print("Trying to create logfile", str(log_path))17 15 log_path.touch() 18 16 except PermissionError: 19 # print("Logging to file disabled")20 17 conf_file = Path(__file__).parent / 'ammos_logging.conf' 21 18 print("Conf file", conf_file) 22 19 logging.config.fileConfig(conf_file) 23 20 else: 24 # print("Logging to", str(log_path))25 21 logging.basicConfig(filename=str(log_path), encoding='utf-8', level=logging.DEBUG) 26 22 27 23 logger = logging.getLogger(__name__) 28 29 logger.warning("Text") -
org/README.org
rdff8988 rb00fbbb 7 7 * Installation 8 8 9 ** Standard pip install (not tested on all platforms) 10 9 11 #+BEGIN_SRC shell 10 12 git clone http://gitlab.kid.local/kidzg/ammosreader.git … … 13 15 #+END_SRC 14 16 17 ** Using the guix functional package manager 18 19 First subscribe to the GUIX oai channel (see Chapter Add channel to system) in 20 https://gitlab.kid.local/kidzg/guix-deployment/-/blob/master/DevOps.org) 21 22 Then install using the guix 23 24 #+BEGIN_SRC shell 25 guix package -i python-ammosreader 26 #+END_SRC 27 15 28 * Usage 16 29 17 The sample_scripts subdirectory contains multiple scripts. 18 19 ** audio_reader.py 20 21 #+BEGIN_SRC shell 22 python3 audio_reader.py 'path_to_ammos_file' 23 #+END_SRC 30 There are two scripts, which demonstrate the usage of the ammosreader package. 24 31 25 32 ** iqdw_reader.py … … 34 41 python3 pdw_reader.py 'path_to_pdw_file' 35 42 #+END_SRC 43 44 To minimize depencencies of the core package other scripts (audio_reader, ammos_viewer) 45 are now stored in separate packages. 46 47 * Logging 48 49 If you use ammosreader in your own scripts a logger can be imported and used as follows: 50 51 #+BEGIN_SRC python 52 from ammosreader import logger 53 logger.warning("Put your warning here") 54 #+END_SRC 55 56 The name of the logfile is ammos.log 57 The logger uses the directory stored in the AMMOS_LOG_DIR environment variable. 58 If this variable is not set, /tmp is used as default. 59 If the logfile is not writable, the standard logger config is used and 60 the logs go directly to console (tty). 61 (see ammos_logging.conf file in this repository)
Note:
See TracChangeset
for help on using the changeset viewer.