Skip to content

Commit

Permalink
Fix Nonetype error
Browse files Browse the repository at this point in the history
  • Loading branch information
freQniK committed May 4, 2024
1 parent f176eb1 commit e7761f8
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions meile_plan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import scrtxxs


VERSION=20240415.0012
VERSION=20240503.2336

app = Flask(__name__)
mysql = MySQL()
Expand Down Expand Up @@ -140,19 +140,19 @@ def GetPlanCostDenom(uuid):

def CheckRenewalStatus(subid, wallet):

query = f"SELECT subscription_id, subscribe_date FROM meile_subscriptions WHERE wallet = '{wallet}' AND subscription_id = {subid}"
query = f"SELECT subscription_id, subscribe_date, expires FROM meile_subscriptions WHERE wallet = '{wallet}' AND subscription_id = {subid}"
c = GetDBCursor()
c.execute(query)

results = c.fetchone()

if results is not None:
if results[0] and results[1]:
return True,results[1]
return True,results[1],results[2]
else:
return False, None
return False, None, None
else:
return False, None
return False, None, None

@app.route('/v1/add', methods=['POST'])
@auth.login_required
Expand Down Expand Up @@ -187,10 +187,17 @@ def add_wallet_to_plan():
print(PlanTX)
return jsonify(PlanTX)

renewal,subscription_date = CheckRenewalStatus(sub_id, wallet)
renewal,subscription_date, expiration = CheckRenewalStatus(sub_id, wallet)

now = datetime.now()
expires = now + relativedelta(months=+duration)
if expiration:
if now < expiration:
expires = expiration + relativedelta(months=+duration)
else:
expires = now + relativedelta(months=+duration)

else:
expires = now + relativedelta(months=+duration)


WalletLogFile = os.path.join(WalletLogDIR, "meile_plan.log")
Expand Down

0 comments on commit e7761f8

Please sign in to comment.