Merge pull request #665 from pinkavaj/pi-rm-py2

Remove Python 2 compatibility hacks
pull/663/head
Mark Jessop 2022-09-21 20:26:51 +09:30 zatwierdzone przez GitHub
commit a8dffa4f31
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
15 zmienionych plików z 23 dodań i 124 usunięć

Wyświetl plik

@ -17,6 +17,7 @@ import time
import traceback
import os
from dateutil.parser import parse
from queue import Queue
if sys.version_info < (3, 6):
print("CRITICAL - radiosonde_auto_rx requires Python 3.6 or newer!")
@ -49,13 +50,6 @@ from autorx.web import (
from autorx.gpsd import GPSDAdaptor
from autorx.sdr_wrappers import shutdown_sdr
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
# Logging level
# INFO = Basic status messages

Wyświetl plik

@ -5,12 +5,7 @@
# Copyright (C) 2018 Mark Jessop <vk5qi@rfhead.net>
# Released under GNU GPL v3 or later
#
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
from queue import Queue
# Now using Semantic Versioning (https://semver.org/) MAJOR.MINOR.PATCH
# MAJOR - Only updated when something huge changes to the project (new decode chain, etc)

Wyświetl plik

@ -11,17 +11,11 @@ import random
import time
import traceback
import socket
from queue import Queue
from threading import Thread, Lock
from . import __version__ as auto_rx_version
from .utils import strip_sonde_serial
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
def telemetry_to_aprs_position(
sonde_data, object_name="<id>", aprs_comment="BOM Balloon", position_report=False

Wyświetl plik

@ -11,6 +11,7 @@ import logging
import os
import traceback
import json
from configparser import RawConfigParser
from .sdr_wrappers import test_sdr
# Dummy initial config with some parameters we need to make the web interface happy.
@ -26,13 +27,6 @@ global_config = {
# Web interface credentials
web_password = "none"
try:
# Python 2
from ConfigParser import RawConfigParser
except ImportError:
# Python 3
from configparser import RawConfigParser
# Fixed minimum update rates for APRS & Habitat
# These are set to avoid congestion on the APRS-IS network, and on the Habitat server
# Please respect other users of these networks and leave these settings as they are.

Wyświetl plik

@ -11,19 +11,12 @@ import time
import smtplib
from email.mime.text import MIMEText
from email.utils import formatdate
from queue import Queue
from threading import Thread
from .config import read_auto_rx_config
from .utils import position_info, strip_sonde_serial
from .geometry import GenericTrack
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
class EmailNotification(object):
""" Radiosonde Email Notification Class.

Wyświetl plik

@ -15,16 +15,10 @@ import traceback
import json
from base64 import b64encode
from hashlib import sha256
from queue import Queue
from threading import Thread, Lock
from . import __version__ as auto_rx_version
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
# These get replaced out after init
url_habitat_uuids = ""
url_habitat_db = ""

Wyświetl plik

@ -10,15 +10,9 @@ import glob
import logging
import os
import time
from queue import Queue
from threading import Thread
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
class TelemetryLogger(object):
""" Radiosonde Telemetry Logger Class.

Wyświetl plik

@ -10,15 +10,9 @@ import json
import logging
import socket
import time
from queue import Queue
from threading import Thread
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
class OziUploader(object):
""" Push radiosonde telemetry out via UDP broadcast to the Horus Chase-Car Utilities

Wyświetl plik

@ -10,16 +10,10 @@ import socket
import time
import numpy as np
from queue import Queue
from threading import Thread, Lock
from autorx.utils import position_info
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
def read_rotator(rotctld_host="localhost", rotctld_port=4533, timeout=5):
""" Attempt to read a position from a rotctld server.

Wyświetl plik

@ -13,6 +13,7 @@ import platform
import subprocess
import time
import traceback
from io import StringIO
from threading import Thread, Lock
from types import FunctionType, MethodType
from .utils import (
@ -24,12 +25,6 @@ from .utils import (
)
from .sdr_wrappers import *
try:
# Python 2
from StringIO import StringIO
except ImportError:
# Python 3
from io import StringIO
try:
from .web import flask_emit_event

Wyświetl plik

@ -18,16 +18,10 @@ import logging
import os
import requests
import time
from queue import Queue
from threading import Thread
from email.utils import formatdate
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
class SondehubUploader(object):
""" Sondehub Uploader Class.
@ -83,20 +77,10 @@ class SondehubUploader(object):
# Record of when we last uploaded a user station position to Sondehub.
self.last_user_position_upload = 0
try:
# Python 2 check. Python 2 doesnt have gzip.compress so this will throw an exception.
gzip.compress(b"\x00\x00")
# Start queue processing thread.
self.input_processing_running = True
self.input_process_thread = Thread(target=self.process_queue)
self.input_process_thread.start()
except:
logging.error(
"Detected Python 2.7, which does not support gzip.compress. Sondehub DB uploading will be disabled."
)
self.input_processing_running = False
# Start queue processing thread.
self.input_processing_running = True
self.input_process_thread = Thread(target=self.process_queue)
self.input_process_thread.start()
def update_station_position(self, lat, lon, alt):
""" Update the internal station position record. Used when determining the station position by GPSD """

Wyświetl plik

@ -22,15 +22,9 @@ import semver
from dateutil.parser import parse
from datetime import datetime, timedelta
from math import radians, degrees, sin, cos, atan2, sqrt, pi
from queue import Queue
from . import __version__ as auto_rx_version
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
# List of binaries we check for on startup
REQUIRED_RS_UTILS = [
@ -723,8 +717,7 @@ def is_not_linux():
# Second check for the existence of '-Microsoft' in the uname release field.
# This is a good check that we are running in WSL.
# Note the use of indexing instead of the named field, for Python 2 & 3 compatability.
if "Microsoft" in platform.uname()[2]:
if "Microsoft" in platform.uname().release:
return True
# Else, we're probably in native Linux!

Wyświetl plik

@ -21,6 +21,7 @@ import autorx.scan
from autorx.geometry import GenericTrack
from autorx.utils import check_autorx_versions
from autorx.log_files import list_log_files, read_log_by_serial, zip_log_files
from queue import Queue
from threading import Thread
import flask
from flask import request, abort, make_response, send_file
@ -35,13 +36,6 @@ except ImportError:
)
sys.exit(1)
try:
# Python 2
from Queue import Queue
except ImportError:
# Python 3
from queue import Queue
# Inhibit Flask warning message about running a development server... (we know!)
cli = sys.modules["flask.cli"]

Wyświetl plik

@ -4,27 +4,17 @@
#
import sys
# Check if we are running in Python 2 or 3
PY3 = sys.version_info[0] == 3
_sample_rate = int(sys.argv[1])
_symbol_rate = int(sys.argv[2])
_bit_length = _sample_rate // _symbol_rate
if PY3:
_zero = b'\x00'*_bit_length
_one = b'\xFF'*_bit_length
_zero = b'\x00'*_bit_length
_one = b'\xFF'*_bit_length
_in = sys.stdin.read
_out = sys.stdout.buffer.write
else:
_zero = '\x00'*_bit_length
_one = '\xFF'*_bit_length
_in = sys.stdin.read
_out = sys.stdout.write
_in = sys.stdin.read
_out = sys.stdout.buffer.write
while True:
_char = _in(1)

Wyświetl plik

@ -13,12 +13,9 @@ import socket, json, sys, traceback
from threading import Thread
from dateutil.parser import parse
from datetime import datetime, timedelta
from io import StringIO
import time
try:
from StringIO import StringIO ## for Python 2
except ImportError:
from io import StringIO ## for Python 3
MAX_JSON_LEN = 32768