2019-08-30 19:24:08 +00:00
|
|
|
#! /bin/env python
|
|
|
|
|
2019-08-29 13:10:35 +00:00
|
|
|
# NanoVNASaver - a python program to view and export Touchstone data from a NanoVNA
|
|
|
|
# Copyright (C) 2019. Rune B. Broberg
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-09-16 13:47:37 +00:00
|
|
|
import logging
|
2019-09-15 21:18:35 +00:00
|
|
|
import sys
|
2019-08-28 13:43:02 +00:00
|
|
|
|
2019-09-10 21:20:59 +00:00
|
|
|
from PyQt5 import QtWidgets, QtCore
|
2019-08-27 14:00:56 +00:00
|
|
|
|
2019-09-04 16:12:38 +00:00
|
|
|
from .NanoVNASaver import NanoVNASaver
|
2019-10-01 12:53:01 +00:00
|
|
|
from .about import debug
|
2019-08-28 12:18:56 +00:00
|
|
|
|
2019-09-04 16:12:38 +00:00
|
|
|
|
|
|
|
def main():
|
2019-09-05 12:56:40 +00:00
|
|
|
print("NanoVNASaver " + NanoVNASaver.version)
|
2019-08-30 07:43:18 +00:00
|
|
|
print("Copyright (C) 2019 Rune B. Broberg")
|
|
|
|
print("This program comes with ABSOLUTELY NO WARRANTY")
|
|
|
|
print("This program is licensed under the GNU General Public License version 3")
|
|
|
|
print("")
|
|
|
|
print("See https://github.com/mihtjel/nanovna-saver for further details")
|
2019-08-27 14:00:56 +00:00
|
|
|
# Main code goes here
|
2019-09-16 20:49:21 +00:00
|
|
|
console_log_level = logging.WARNING
|
|
|
|
file_log_level = logging.DEBUG
|
|
|
|
log_file = ""
|
|
|
|
|
|
|
|
for i in range(len(sys.argv)):
|
|
|
|
if sys.argv[i] == "-d":
|
|
|
|
console_log_level = logging.DEBUG
|
|
|
|
elif sys.argv[i] == "-D" and i < len(sys.argv) - 1:
|
|
|
|
log_file = sys.argv[i+1]
|
|
|
|
elif sys.argv[i] == "-D":
|
|
|
|
print("You must enter a file name when using -D")
|
|
|
|
return
|
2019-09-16 13:47:37 +00:00
|
|
|
|
2019-10-01 12:53:01 +00:00
|
|
|
if debug:
|
|
|
|
console_log_level = logging.DEBUG
|
|
|
|
|
2019-09-16 13:47:37 +00:00
|
|
|
logger = logging.getLogger("NanoVNASaver")
|
2019-09-16 19:41:01 +00:00
|
|
|
logger.setLevel(logging.DEBUG)
|
2019-09-16 13:47:37 +00:00
|
|
|
ch = logging.StreamHandler()
|
2019-09-16 20:49:21 +00:00
|
|
|
ch.setLevel(console_log_level)
|
2019-09-16 13:47:37 +00:00
|
|
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
|
|
ch.setFormatter(formatter)
|
|
|
|
logger.addHandler(ch)
|
2019-09-16 20:49:21 +00:00
|
|
|
if log_file != "":
|
|
|
|
try:
|
|
|
|
fh = logging.FileHandler(log_file)
|
|
|
|
except Exception as e:
|
|
|
|
logger.exception("Error opening log file: %s", e)
|
|
|
|
return
|
|
|
|
|
|
|
|
fh.setLevel(file_log_level)
|
|
|
|
fh.setFormatter(formatter)
|
|
|
|
logger.addHandler(fh)
|
|
|
|
|
2019-09-16 13:47:37 +00:00
|
|
|
logger.info("Startup...")
|
|
|
|
|
2019-09-10 21:20:59 +00:00
|
|
|
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
|
2019-09-15 21:18:35 +00:00
|
|
|
app = QtWidgets.QApplication(sys.argv)
|
2019-08-27 14:00:56 +00:00
|
|
|
window = NanoVNASaver()
|
|
|
|
window.show()
|
|
|
|
app.exec_()
|
2019-09-04 16:12:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|