Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # omissis
- elif tag=='configuremonitor':
- endpoint = f"{settings['Shinobi']['url']}:{settings['Shinobi']['port']}/{settings['Shinobi']['api_key']}/configureMonitor/{settings['Shinobi']['group_key']}/{selection}"
- queryurl = f"{settings['Shinobi']['url']}:{settings['Shinobi']['port']}/{settings['Shinobi']['api_key']}/monitor/{settings['Shinobi']['group_key']}/{selection}"
- response = requests.get(queryurl)
- if response.status_code != 200:
- print(f'Error {response.status_code} something went wrong, request error \u26A0\ufe0f')
- await context.bot.send_message(chat_id=update.effective_chat.id, text='Error something went wrong, request error \u26A0\ufe0f')
- return
- else:
- print(f'OK, server touched... \U0001F44D')
- await context.bot.send_message(chat_id=update.effective_chat.id, text=f'OK, done \U0001F44D')
- data=disAssebleMonitor(response.json())
- print(f'posting data: \n {data}')
- response = requests.post(endpoint, data=data)
- if response.status_code != 200:
- print(f'Error {response.status_code} something went wrong, request error \u26A0\ufe0f')
- print(response.text)
- await context.bot.send_message(chat_id=update.effective_chat.id, text='Error something went wrong, request error \u26A0\ufe0f')
- return
- else:
- print(f'OK, done \U0001F44D')
- print(response.text)
- await context.bot.send_message(chat_id=update.effective_chat.id, text=f'OK, done \U0001F44D')
- def disAssebleMonitor(response):
- print('disassembling monitor...')
- #response = response.json()
- monitor=response[0]
- monitor['details']=json.loads(monitor.get('details'))
- monitor['details']['snap'] = "1"
- #monitor['details']=str(monitor.get('details'))
- # monitor.pop('details')
- print('reassembling monitor...')
- # Needed keys to make API query
- keys=['mode', 'mid', 'name', 'tags', 'type', 'protocol', 'host', 'port', 'path', 'height', 'width', 'ext', 'fps', 'details']
- query={}
- for key in keys:
- query[key]=monitor.get(key)
- return(json.dumps(query, indent=4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement