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
This commit is contained in:
parent
cdf349bc64
commit
59debdcd07
|
@ -29,6 +29,17 @@ class ApplicationBase:
|
||||||
# Example: [DEBUG] ctrl_if_bts.py:71 Recv POWEROFF cmd
|
# Example: [DEBUG] ctrl_if_bts.py:71 Recv POWEROFF cmd
|
||||||
LOG_FMT_DEFAULT = "[%(levelname)s] %(filename)s:%(lineno)d %(message)s"
|
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):
|
def app_init_logging(self, argv):
|
||||||
# Default logging handler (stderr)
|
# Default logging handler (stderr)
|
||||||
sh = log.StreamHandler()
|
sh = log.StreamHandler()
|
||||||
|
|
|
@ -23,8 +23,7 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
from copyright import print_copyright
|
APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
||||||
CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
|
||||||
|
|
||||||
import logging as log
|
import logging as log
|
||||||
import signal
|
import signal
|
||||||
|
@ -40,7 +39,7 @@ from data_msg import *
|
||||||
|
|
||||||
class Application(ApplicationBase):
|
class Application(ApplicationBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
print_copyright(CR_HOLDERS)
|
self.app_print_copyright(APP_CR_HOLDERS)
|
||||||
self.argv = self.parse_argv()
|
self.argv = self.parse_argv()
|
||||||
|
|
||||||
# Set up signal handlers
|
# Set up signal handlers
|
||||||
|
|
|
@ -22,8 +22,7 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
from copyright import print_copyright
|
APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
||||||
CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
|
||||||
|
|
||||||
import logging as log
|
import logging as log
|
||||||
import signal
|
import signal
|
||||||
|
@ -38,7 +37,7 @@ from data_msg import *
|
||||||
|
|
||||||
class Application(ApplicationBase):
|
class Application(ApplicationBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
print_copyright(CR_HOLDERS)
|
self.app_print_copyright(APP_CR_HOLDERS)
|
||||||
self.argv = self.parse_argv()
|
self.argv = self.parse_argv()
|
||||||
|
|
||||||
# Set up signal handlers
|
# Set up signal handlers
|
||||||
|
|
|
@ -22,14 +22,14 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
from copyright import print_copyright
|
APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
||||||
CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
|
||||||
|
|
||||||
import logging as log
|
import logging as log
|
||||||
import signal
|
import signal
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from app_common import ApplicationBase
|
||||||
from threading import Timer
|
from threading import Timer
|
||||||
from udp_link import UDPLink
|
from udp_link import UDPLink
|
||||||
from gsm_shared import *
|
from gsm_shared import *
|
||||||
|
@ -94,10 +94,10 @@ class CLCKGen:
|
||||||
self.timer.start()
|
self.timer.start()
|
||||||
|
|
||||||
# Just a wrapper for independent usage
|
# Just a wrapper for independent usage
|
||||||
class Application:
|
class Application(ApplicationBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Print copyright
|
# Print copyright
|
||||||
print_copyright(CR_HOLDERS)
|
self.app_print_copyright(APP_CR_HOLDERS)
|
||||||
|
|
||||||
# Set up signal handlers
|
# Set up signal handlers
|
||||||
signal.signal(signal.SIGINT, self.sig_handler)
|
signal.signal(signal.SIGINT, self.sig_handler)
|
||||||
|
|
|
@ -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")
|
|
|
@ -23,8 +23,7 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
from copyright import print_copyright
|
APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
||||||
CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
|
||||||
|
|
||||||
import logging as log
|
import logging as log
|
||||||
import signal
|
import signal
|
||||||
|
@ -37,7 +36,7 @@ from udp_link import UDPLink
|
||||||
|
|
||||||
class Application(ApplicationBase):
|
class Application(ApplicationBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
print_copyright(CR_HOLDERS)
|
self.app_print_copyright(APP_CR_HOLDERS)
|
||||||
self.argv = self.parse_argv()
|
self.argv = self.parse_argv()
|
||||||
|
|
||||||
# Set up signal handlers
|
# Set up signal handlers
|
||||||
|
|
|
@ -22,8 +22,7 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
from copyright import print_copyright
|
APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
||||||
CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
|
||||||
|
|
||||||
import logging as log
|
import logging as log
|
||||||
import signal
|
import signal
|
||||||
|
@ -42,7 +41,7 @@ from clck_gen import CLCKGen
|
||||||
|
|
||||||
class Application(ApplicationBase):
|
class Application(ApplicationBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
print_copyright(CR_HOLDERS)
|
self.app_print_copyright(APP_CR_HOLDERS)
|
||||||
self.argv = self.parse_argv()
|
self.argv = self.parse_argv()
|
||||||
|
|
||||||
# Set up signal handlers
|
# Set up signal handlers
|
||||||
|
|
|
@ -22,8 +22,7 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
from copyright import print_copyright
|
APP_CR_HOLDERS = [("2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
||||||
CR_HOLDERS = [("2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
|
|
||||||
|
|
||||||
import logging as log
|
import logging as log
|
||||||
import signal
|
import signal
|
||||||
|
@ -48,7 +47,7 @@ class Application(ApplicationBase):
|
||||||
lo_trigger = False
|
lo_trigger = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
print_copyright(CR_HOLDERS)
|
self.app_print_copyright(APP_CR_HOLDERS)
|
||||||
self.argv = self.parse_argv()
|
self.argv = self.parse_argv()
|
||||||
|
|
||||||
# Configure logging
|
# Configure logging
|
||||||
|
|
Loading…
Reference in New Issue