2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-08-03 16:07:00 +00:00
Files
confluent/misc/fixexpiry.py
T
Markus Hilger 2af402b13c ruff auto fixes
Apply ruff's safe autofixes.
The changes are mechanical and behaviour-preserving. Issues fixed:

- F401: remove unused imports.
- F841: drop unused local variables and assignments, including discarded
  await/return values, unused "except ... as e" bindings, and unused
  "with ... as name" targets.
- F541: remove the f prefix from f-strings that contain no placeholders.
- E711: compare against None with "is"/"is not" instead of "=="/"!=".
- E712: test truthiness directly instead of comparing to True.
- E713: use "x not in y" instead of "not x in y".
- E714: use "is not" instead of "not ... is".
- E731: convert lambdas bound to a name into def statements.
- W291/W293: trim trailing whitespace on touched lines.
2026-07-14 05:03:58 +02:00

46 lines
1.8 KiB
Python

#!/usr/bin/python2
import pyghmi.util.webclient as webclient
import json
import os
import sys
tmppassword = 'to3BdS91ABrd'
missingargs = False
if 'XCCUSER' not in os.environ:
print('Must set XCCUSER environment variable')
missingargs = True
if 'XCCPASS' not in os.environ:
print('Must set XCCPASS environment variable')
missingargs = True
if missingargs:
sys.exit(1)
w = webclient.SecureHTTPConnection(sys.argv[1], 443, verifycallback=lambda x: True)
w.connect()
adata = json.dumps({'username': os.environ['XCCUSER'], 'password': os.environ['XCCPASS']})
headers = {'Connection': 'keep-alive', 'Content-Type': 'application/json'}
w.request('POST', '/api/login', adata, headers)
rsp = w.getresponse()
if rsp.status != 200:
rsp.read()
adata = json.dumps({'username': os.environ['XCCUSER'], 'password': tmppassword})
headers = {'Connection': 'keep-alive', 'Content-Type': 'application/json'}
w.request('POST', '/api/login', adata, headers)
rsp = w.getresponse()
if rsp.status == 200:
rspdata = json.loads(rsp.read())
w.set_header('Content-Type', 'application/json')
w.set_header('Authorization', 'Bearer ' + rspdata['access_token'])
if '_csrf_token' in w.cookies:
w.set_header('X-XSRF-TOKEN', w.cookies['_csrf_token'])
if rspdata.get('pwchg_required', False):
print(repr(w.grab_json_response('/api/function', {'USER_UserPassChange': '1,to3BdS91ABrd'})))
print(repr(w.grab_json_response('/api/dataset', {
'USER_GlobalPassExpWarningPeriod': '0',
'USER_GlobalPassExpPeriod': '0',
'USER_GlobalMinPassReuseCycle': '0',
'USER_GlobalMinPassChgInt': '0',
})))
print(repr(w.grab_json_response('/api/function', {'USER_UserPassChange': '1,' + os.environ['XCCPASS']})))