# -*- coding: utf-8 -*- import json import requests import datetime class ActionReport(object): version = '1.0.0' base_url = '//cloud.actioncharts.com/Reports1.1/WS/UploadReports.svc/json/UploadReports' def __init__(self, passcode, name1, name2, email, info="", decimal=".", separator=",", use_ssl=True): self._passcode = passcode self._name1 = name1 self._name2 = name2 self._emails = ("Operators Group", email) self._info = info self._decimal = decimal self._separator = separator self._url = ('https:' if use_ssl else 'http:') + self.base_url self._headers = {} self._data = {} self._tags = [] self._timestamp = "" def add_tag(self, name, value, info="", color="White"): self._tags.append({"Name":name, "Value":value, "DisplayInfo":info, "Color":color}) def update(self): self._timestamp = datetime.datetime.now().strftime("%m/%d/%y %I:%M %p") self._data.update({"Request": {"Passcode":self._passcode, "ReportList":{"TagViewReports":[ {"AllowedGroups":self._emails, "DisplayInfo":self._info, "NameLine1":self._name1, "NameLine2":self._name2, "NameLine3":self._timestamp, "ThousandsSeparator":self._separator, "DecimalSymbol":self._decimal, "TagInstances":[ {"TagTimestampString":self._timestamp, "Tags":self._tags}]}]}}}) self._headers['Content-Type'] = 'application/json; charset=utf-8' self._headers['Host'] = 'cloud.actioncharts.com' r = requests.post(self._url, data=json.dumps(self._data), headers=self._headers) self._data.clear() del self._tags[:] return r
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question