summaryrefslogtreecommitdiffstats
path: root/src/target
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-12-07 10:04:14 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-12-08 02:10:50 +0700
commit59debdcd073c9c703965ebed5f60fe9777f2cd6b (patch)
tree1f30132a364dd341aa80f3132cd69013d4762928 /src/target
parentcdf349bc645d36645dab13e3f975b4deafbee579 (diff)
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
Diffstat (limited to 'src/target')
-rw-r--r--src/target/trx_toolkit/app_common.py11
-rwxr-xr-xsrc/target/trx_toolkit/burst_gen.py5
-rwxr-xr-xsrc/target/trx_toolkit/burst_send.py5
-rwxr-xr-xsrc/target/trx_toolkit/clck_gen.py8
-rw-r--r--src/target/trx_toolkit/copyright.py13
-rwxr-xr-xsrc/target/trx_toolkit/ctrl_cmd.py5
-rwxr-xr-xsrc/target/trx_toolkit/fake_trx.py5
-rwxr-xr-xsrc/target/trx_toolkit/trx_sniff.py5
8 files changed, 25 insertions, 32 deletions
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 " \
+ "<http://gnu.org/licenses/gpl.html>\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 <axilirator@gmail.com>")]
+APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
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 <axilirator@gmail.com>")]
+APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
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 <axilirator@gmail.com>")]
+APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
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 " \
- "<http://gnu.org/licenses/gpl.html>\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 <axilirator@gmail.com>")]
+APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
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 <axilirator@gmail.com>")]
+APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
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 <axilirator@gmail.com>")]
+APP_CR_HOLDERS = [("2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
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