Created
December 2, 2011 12:33
-
-
Save kirelagin/1423082 to your computer and use it in GitHub Desktop.
PCMS2 contest status and time remaining
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
import sys | |
import datetime | |
from mustaine.client import HessianProxy | |
SERVICE_URL = 'http://neerc.ifmo.ru:8081/pcms/party' | |
LOGIN = '<login>' | |
PASSWORD = '<password>' | |
service = HessianProxy(SERVICE_URL) | |
clock = service.getLoginData(LOGIN, PASSWORD).clock | |
def format_date(datetime): | |
return datetime.strftime('%A, %d %b %Y %H:%M') | |
if clock.status == 1: | |
print('BEFORE') | |
print('Starts: ' + format_date(datetime.datetime.fromtimestamp(clock.startTime / 1000))) | |
elif clock.status == 4: | |
print('OVER') | |
print('Ended: ' + format_date(datetime.datetime.fromtimestamp((clock.startTime + clock.length) / 1000))) | |
else: | |
left = clock.length - clock.time | |
delta = datetime.timedelta(milliseconds=left) | |
end = datetime.datetime.now() + delta | |
print('Ends: ' + format_date(end)) | |
print('(' + str(delta) + ' left)') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment