mirror of
https://github.com/coulisse/spiderweb.git
synced 2024-09-21 07:27:09 +00:00
Plots: callsign enlarged #51
This commit is contained in:
parent
b6fabbdb92
commit
2a05d05de4
@ -13,7 +13,9 @@ def parse_who(lines):
|
||||
|
||||
# create a list o lines and define the structure
|
||||
lines = lines.splitlines()
|
||||
fmtstring = "2x 9s 10s 18s 9s 8s 15s"
|
||||
#fmtstring = "2x 9s 10s 18s 9s 8s 15s"
|
||||
#fmtstring = "10s 18s 9s 8s 15s"
|
||||
fmtstring = "10s 18s 9s"
|
||||
fieldstruct = struct.Struct(fmtstring)
|
||||
|
||||
row_headers = ("callsign", "type", "started", "name", "average_rtt", "link")
|
||||
@ -21,24 +23,27 @@ def parse_who(lines):
|
||||
# skip first lines and last line
|
||||
payload = []
|
||||
for i in range(3, len(lines) - 1):
|
||||
line = lines[i]
|
||||
ln = len(line)
|
||||
|
||||
padding = bytes(" " * (struct.calcsize(fmtstring) - ln), "utf-8")
|
||||
line = line + padding
|
||||
#line = lines[i]
|
||||
line = lines[i].lstrip().decode("utf-8")
|
||||
|
||||
line_splitted_by_first_space = line.split(" ", 1)
|
||||
first_part = line_splitted_by_first_space[0]
|
||||
second_part = line_splitted_by_first_space[1]
|
||||
|
||||
ln = len(second_part)
|
||||
|
||||
if ln > 10:
|
||||
fields = [first_part.encode()] #adding callsign
|
||||
parse = fieldstruct.unpack_from
|
||||
fields = list(parse(line))
|
||||
fields += list(parse(second_part.encode())) #adding rest of informations
|
||||
|
||||
for j, item_field in enumerate(fields):
|
||||
try:
|
||||
fields[j] = item_field.decode("utf-8").strip()
|
||||
except AttributeError:
|
||||
print(item_field)
|
||||
payload.append(dict(zip(row_headers, fields)))
|
||||
logging.error(item_field)
|
||||
|
||||
# payload = json.dumps(payload)
|
||||
payload.append(dict(zip(row_headers, fields)))
|
||||
|
||||
return payload
|
||||
|
||||
|
@ -37,21 +37,15 @@ class query_manager:
|
||||
|
||||
self.__cnxpool = my.ConnectionPool(
|
||||
host=cfg["mysql"]["host"],
|
||||
#port=3306,
|
||||
user=cfg["mysql"]["user"],
|
||||
passwd=cfg["mysql"]["passwd"],
|
||||
db=cfg["mysql"]["db"],
|
||||
# charset="latin1",
|
||||
pool_name="spider_pool",
|
||||
# use_pure=True,
|
||||
pool_size=3,
|
||||
pool_size=5,
|
||||
pool_validation_interval=250
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
logging.info("db connection pool created")
|
||||
|
||||
# normal query
|
||||
|
@ -186,6 +186,4 @@ def query_build(logger,parameters,band_frequencies,modes_frequencies,continents_
|
||||
return query_string
|
||||
|
||||
|
||||
def query_build_callsing_list():
|
||||
query_string = "SELECT spotcall AS dx FROM (select spotcall from spot order by rowid desc limit 50000) s1 GROUP BY spotcall ORDER BY count(spotcall) DESC, spotcall LIMIT 100;"
|
||||
return query_string
|
||||
query_build_callsing_list = lambda: 'SELECT spotcall AS dx FROM (select spotcall from spot order by rowid desc limit 50000) s1 GROUP BY spotcall ORDER BY count(spotcall) DESC, spotcall LIMIT 100;'
|
@ -17,6 +17,7 @@ import requests
|
||||
import xmltodict
|
||||
from lib.qry_builder import query_build, query_build_callsign, query_build_callsing_list
|
||||
|
||||
|
||||
logging.config.fileConfig("cfg/webapp_log_config.ini", disable_existing_loggers=True)
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info("Starting SPIDERWEB")
|
||||
@ -116,7 +117,6 @@ def spotquery(parameters):
|
||||
else:
|
||||
logging.debug('search eith other filters')
|
||||
query_string = query_build(logger,parameters,band_frequencies,modes_frequencies,continents_cq,enable_cq_filter)
|
||||
|
||||
qm.qry(query_string)
|
||||
data = qm.get_data()
|
||||
row_headers = qm.get_headers()
|
||||
@ -226,8 +226,9 @@ def spots():
|
||||
|
||||
#Show all dx spot callsigns
|
||||
def get_dx_calls():
|
||||
|
||||
try:
|
||||
query_string = query_build_callsing_list
|
||||
query_string = query_build_callsing_list()
|
||||
qm.qry(query_string)
|
||||
data = qm.get_data()
|
||||
row_headers = qm.get_headers()
|
||||
|
Loading…
Reference in New Issue
Block a user