From 59debdcd073c9c703965ebed5f60fe9777f2cd6b Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Fri, 7 Dec 2018 10:04:14 +0700 Subject: trx_toolkit: merge copyright.py into app_common.py Since we have introduced ApplicationBase class, that are used by all existing applications, let's merge the copyright printing helper into it. Change-Id: I8b70ec2dd08cb2ffed733d2c4e1215b094f8d3d5 --- src/target/trx_toolkit/app_common.py | 11 +++++++++++ src/target/trx_toolkit/burst_gen.py | 5 ++--- src/target/trx_toolkit/burst_send.py | 5 ++--- src/target/trx_toolkit/clck_gen.py | 8 ++++---- src/target/trx_toolkit/copyright.py | 13 ------------- src/target/trx_toolkit/ctrl_cmd.py | 5 ++--- src/target/trx_toolkit/fake_trx.py | 5 ++--- src/target/trx_toolkit/trx_sniff.py | 5 ++--- 8 files changed, 25 insertions(+), 32 deletions(-) delete mode 100644 src/target/trx_toolkit/copyright.py (limited to 'src') diff --git a/src/target/trx_toolkit/app_common.py b/src/target/trx_toolkit/app_common.py index 180e97ca..9bcd5930 100644 --- a/src/target/trx_toolkit/app_common.py +++ b/src/target/trx_toolkit/app_common.py @@ -29,6 +29,17 @@ class ApplicationBase: # Example: [DEBUG] ctrl_if_bts.py:71 Recv POWEROFF cmd LOG_FMT_DEFAULT = "[%(levelname)s] %(filename)s:%(lineno)d %(message)s" + def app_print_copyright(self, holders = []): + # Print copyright holders if any + for date, author in holders: + print("Copyright (C) %s by %s" % (date, author)) + + # Print the license header itself + print("License GPLv2+: GNU GPL version 2 or later " \ + "\n" \ + "This is free software: you are free to change and redistribute it.\n" \ + "There is NO WARRANTY, to the extent permitted by law.\n") + def app_init_logging(self, argv): # Default logging handler (stderr) sh = log.StreamHandler() diff --git a/src/target/trx_toolkit/burst_gen.py b/src/target/trx_toolkit/burst_gen.py index 1c18b3cc..b62f48c5 100755 --- a/src/target/trx_toolkit/burst_gen.py +++ b/src/target/trx_toolkit/burst_gen.py @@ -23,8 +23,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -from copyright import print_copyright -CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy ")] +APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy ")] import logging as log import signal @@ -40,7 +39,7 @@ from data_msg import * class Application(ApplicationBase): def __init__(self): - print_copyright(CR_HOLDERS) + self.app_print_copyright(APP_CR_HOLDERS) self.argv = self.parse_argv() # Set up signal handlers diff --git a/src/target/trx_toolkit/burst_send.py b/src/target/trx_toolkit/burst_send.py index 16db222f..3745b397 100755 --- a/src/target/trx_toolkit/burst_send.py +++ b/src/target/trx_toolkit/burst_send.py @@ -22,8 +22,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -from copyright import print_copyright -CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy ")] +APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy ")] import logging as log import signal @@ -38,7 +37,7 @@ from data_msg import * class Application(ApplicationBase): def __init__(self): - print_copyright(CR_HOLDERS) + self.app_print_copyright(APP_CR_HOLDERS) self.argv = self.parse_argv() # Set up signal handlers diff --git a/src/target/trx_toolkit/clck_gen.py b/src/target/trx_toolkit/clck_gen.py index 56207f46..40964ddd 100755 --- a/src/target/trx_toolkit/clck_gen.py +++ b/src/target/trx_toolkit/clck_gen.py @@ -22,14 +22,14 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -from copyright import print_copyright -CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy ")] +APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy ")] import logging as log import signal import time import sys +from app_common import ApplicationBase from threading import Timer from udp_link import UDPLink from gsm_shared import * @@ -94,10 +94,10 @@ class CLCKGen: self.timer.start() # Just a wrapper for independent usage -class Application: +class Application(ApplicationBase): def __init__(self): # Print copyright - print_copyright(CR_HOLDERS) + self.app_print_copyright(APP_CR_HOLDERS) # Set up signal handlers signal.signal(signal.SIGINT, self.sig_handler) diff --git a/src/target/trx_toolkit/copyright.py b/src/target/trx_toolkit/copyright.py deleted file mode 100644 index 3d3597fd..00000000 --- a/src/target/trx_toolkit/copyright.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- - -def print_copyright(holders = []): - # Print copyright holders if any - for date, author in holders: - print("Copyright (C) %s by %s" % (date, author)) - - # Print the license header itself - print("License GPLv2+: GNU GPL version 2 or later " \ - "\n" \ - "This is free software: you are free to change and redistribute it.\n" \ - "There is NO WARRANTY, to the extent permitted by law.\n") diff --git a/src/target/trx_toolkit/ctrl_cmd.py b/src/target/trx_toolkit/ctrl_cmd.py index ffc3e467..28815c28 100755 --- a/src/target/trx_toolkit/ctrl_cmd.py +++ b/src/target/trx_toolkit/ctrl_cmd.py @@ -23,8 +23,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -from copyright import print_copyright -CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy ")] +APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy ")] import logging as log import signal @@ -37,7 +36,7 @@ from udp_link import UDPLink class Application(ApplicationBase): def __init__(self): - print_copyright(CR_HOLDERS) + self.app_print_copyright(APP_CR_HOLDERS) self.argv = self.parse_argv() # Set up signal handlers diff --git a/src/target/trx_toolkit/fake_trx.py b/src/target/trx_toolkit/fake_trx.py index a45ce203..d73b5662 100755 --- a/src/target/trx_toolkit/fake_trx.py +++ b/src/target/trx_toolkit/fake_trx.py @@ -22,8 +22,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -from copyright import print_copyright -CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy ")] +APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy ")] import logging as log import signal @@ -42,7 +41,7 @@ from clck_gen import CLCKGen class Application(ApplicationBase): def __init__(self): - print_copyright(CR_HOLDERS) + self.app_print_copyright(APP_CR_HOLDERS) self.argv = self.parse_argv() # Set up signal handlers diff --git a/src/target/trx_toolkit/trx_sniff.py b/src/target/trx_toolkit/trx_sniff.py index 7a873510..e169c72e 100755 --- a/src/target/trx_toolkit/trx_sniff.py +++ b/src/target/trx_toolkit/trx_sniff.py @@ -22,8 +22,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -from copyright import print_copyright -CR_HOLDERS = [("2018", "Vadim Yanitskiy ")] +APP_CR_HOLDERS = [("2018", "Vadim Yanitskiy ")] import logging as log import signal @@ -48,7 +47,7 @@ class Application(ApplicationBase): lo_trigger = False def __init__(self): - print_copyright(CR_HOLDERS) + self.app_print_copyright(APP_CR_HOLDERS) self.argv = self.parse_argv() # Configure logging -- cgit v1.2.3