Skip to content

Commit

Permalink
Update scan-and-livemon
Browse files Browse the repository at this point in the history
The import library imp has been removed in python >3.12. The new methodology is to use importlib.util and importlib.machinery per the change notes https://docs.python.org/dev/whatsnew/3.12.html#removed
  • Loading branch information
jabreity authored Jul 3, 2024
1 parent 46af976 commit 6c9b3e3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scan-and-livemon
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,27 @@ stations and phones in the area as possible, by spreading across as
many operators as possible.
"""

import imp
import importlib.util
import importlib.machinery
from optparse import OptionParser
import subprocess
import sys
import distutils.spawn

def load_source(modname, filename):
loader = importlib.machinery.SourceFileLoader(modname, filename)
spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
module = importlib.util.module_from_spec(spec)
loader.exec_module(module)
return module

def find_gsm_bases():
grgsm_scanner_path = distutils.spawn.find_executable("grgsm_scanner")
if grgsm_scanner_path is None:
print("Error : Please install gr-gsm")
exit(1)

scanner = imp.load_source('scanner', grgsm_scanner_path)
scanner = load_source('scanner', grgsm_scanner_path)
sys.modules['scanner'] = scanner
(options, args) = scanner.argument_parser().parse_args() #FIXME conflic with argument_parser line 93
list = scanner.do_scan(options.samp_rate, options.band, options.speed,
Expand Down

0 comments on commit 6c9b3e3

Please sign in to comment.