mirror of
https://github.com/Retropex/raspiblitz.git
synced 2025-05-30 05:52:35 +02:00
list und cancel subscription
This commit is contained in:
parent
189120b77a
commit
cf485c5d07
@ -399,7 +399,6 @@ def shopOrder(shopUrl, hostid, servicename, torTarget, duration, msatsFirst, msa
|
|||||||
|
|
||||||
# load, add and store subscriptions
|
# load, add and store subscriptions
|
||||||
try:
|
try:
|
||||||
#f = open(SUBSCRIPTIONS_FILE,"w")
|
|
||||||
if Path(SUBSCRIPTIONS_FILE).is_file():
|
if Path(SUBSCRIPTIONS_FILE).is_file():
|
||||||
print("# load toml file")
|
print("# load toml file")
|
||||||
subscriptions = toml.load(SUBSCRIPTIONS_FILE)
|
subscriptions = toml.load(SUBSCRIPTIONS_FILE)
|
||||||
@ -774,8 +773,12 @@ if sys.argv[1] == "subscriptions-list":
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# TODO: JSON output of list with all subscrptions
|
if Path(SUBSCRIPTIONS_FILE).is_file():
|
||||||
print("TODO: implement")
|
subs = toml.load(SUBSCRIPTIONS_FILE)
|
||||||
|
else:
|
||||||
|
subs = {}
|
||||||
|
subs['list'] = []
|
||||||
|
print(json.dumps(subs, indent=2))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
handleException(e)
|
handleException(e)
|
||||||
@ -854,11 +857,28 @@ if sys.argv[1] == "subscriptions-renew":
|
|||||||
|
|
||||||
if sys.argv[1] == "subscription-cancel":
|
if sys.argv[1] == "subscription-cancel":
|
||||||
|
|
||||||
|
# check parameters
|
||||||
try:
|
try:
|
||||||
|
subscriptionID = sys.argv[2]
|
||||||
# TODO: JSON output of list with all subscrptions
|
except Exception as e:
|
||||||
print("TODO: implement")
|
handleException(e)
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
subs = toml.load(SUBSCRIPTIONS_FILE)
|
||||||
|
newList = []
|
||||||
|
for idx, sub in enumerate(subs['list']):
|
||||||
|
if sub['id'] != subscriptionID:
|
||||||
|
newList.append(sub)
|
||||||
|
subs['list'] = newList
|
||||||
|
|
||||||
|
# persist change
|
||||||
|
with open(SUBSCRIPTIONS_FILE, 'w') as writer:
|
||||||
|
writer.write(toml.dumps(subs))
|
||||||
|
writer.close()
|
||||||
|
|
||||||
|
print(json.dumps(subs, indent=2))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
handleException(e)
|
handleException(e)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user