-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsoa2fil.py
executable file
·73 lines (69 loc) · 3.5 KB
/
soa2fil.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import sys
import config
import os
import socket
import datetime
import time
from config import *
from soa2filfuncs import soa2fil # import the configuration generated by genconfig.py script
pgmver='2.2'
###################################################################
day = sys.argv[1:] # see if index day is requestedd
execreq = sys.argv[2:] # -e request
FlarmIDr = sys.argv[3:] # -e request the FlarmID
if day and day[0].isdigit(): # if provided and numeric
idx = int(day[0]) # index day
else:
idx = 0
# the FlarmID of the files to be reconstructed
FlarmID = ""
execopt = False
# if we ask to exec the buildIGC
if execreq and execreq[0] == "-e":
if FlarmIDr:
FlarmID = FlarmIDr[0].upper() # get the FlarmID
if len(FlarmID) == 9:
FlarmID = FalrmID[3:9] # in case of form ICAxxxxxx
execopt = True
# ---------------------------------------------------------------- #
print("\nUtility to get the api.soaringspot.com data and extract all the IGC files from the SoaringSpot server", pgmver)
print("==========================================================================================================\n\n")
print("Usage: python soa2fil.py indexday [-e FlarmID ]")
print("==================================================\n\n")
print("Index day: ", idx, "extract:", execopt, "Flarm req: ", FlarmID )
print("Reading data from clientid/secretkey files")
print("==========================================\n\n")
# ---------------------------------------------------------------- #
# ===== SETUP parameters =======================#
# where to get/store the IGC files
SARpath = config.SARpath
cwd = os.getcwd() # get the current working directory
# where to find the clientid and secretkey files
secpath = cwd+"/SoaringSpot/"
# the subdirectory where to store the extracted files
# ==============================================#
hostname = socket.gethostname() # hostname as control
print("Hostname:", hostname)
start_time = time.time() # get the time now
utc = datetime.datetime.utcnow() # the UTC time
# print the time for information only
print("UTC Time is now:", utc)
date = utc.strftime("%Y-%m-%dT%H:%M:%SZ") # get the local time
print(date) #
local_time = datetime.datetime.now() # the local time
print("Local Time is now:", local_time) # print the time for information only
fl_date_time = local_time.strftime("%Y%m%d") # get the local time
print("Config params. SECpath:", secpath)
# open the file with the client id
f = open(secpath+"clientid")
client = f.read() # read it
# clear the whitespace at the end
client = client.rstrip()
# open the file with the secret key
f = open(secpath+"secretkey")
secretkey = f.read() # read it
# clear the whitespace at the end
secretkey = secretkey.rstrip().encode(encoding='utf-8')
soa2fil(client, secretkey, idx, FlarmID,execopt, prt=config.prt) # invoke the extractor