add online checking
This commit is contained in:
parent
b90d12ca89
commit
6950e5f050
12
vk0nline.py
12
vk0nline.py
@ -4,13 +4,13 @@ import json
|
|||||||
import requests
|
import requests
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import getpass
|
import getpass
|
||||||
|
import sys
|
||||||
|
|
||||||
__author__ = 'Alexander Popov'
|
__author__ = 'Alexander Popov'
|
||||||
__copyright__ = '2019 by iiiypuk'
|
__copyright__ = '2019 by iiiypuk'
|
||||||
__credits__ = ['Alexander Popov']
|
__credits__ = ['Alexander Popov']
|
||||||
__license__ = 'Unlicense'
|
__license__ = 'Unlicense'
|
||||||
__version__ = '1.0.2'
|
__version__ = '1.0.3'
|
||||||
__maintainer__ = 'Alexander Popov'
|
__maintainer__ = 'Alexander Popov'
|
||||||
__email__ = 'iiiypuk@fastmail.fm'
|
__email__ = 'iiiypuk@fastmail.fm'
|
||||||
__status__ = 'Production'
|
__status__ = 'Production'
|
||||||
@ -54,11 +54,15 @@ def setOnline():
|
|||||||
print('Error: {}.'.format(content['error']['error_code']))
|
print('Error: {}.'.format(content['error']['error_code']))
|
||||||
elif 'response' in content:
|
elif 'response' in content:
|
||||||
if 1 == content['response']:
|
if 1 == content['response']:
|
||||||
print('Ok!')
|
|
||||||
onlineStatus, lastSeen = getStatus()
|
onlineStatus, lastSeen = getStatus()
|
||||||
lastSeen = datetime.fromtimestamp(lastSeen) \
|
lastSeen = datetime.fromtimestamp(lastSeen) \
|
||||||
.strftime('%Y-%m-%d %H:%M:%S')
|
.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
print(onlineStatus, lastSeen)
|
|
||||||
|
if 0 == onlineStatus:
|
||||||
|
print('Not successful.')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
print('Last online', lastSeen)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user