def processRequest(req): #météo if req.get("result").get("action") == "yahooWeatherForecast": baseurl = "https://query.yahooapis.com/v1/public/yql?" yql_query = makeYqlQuery(req) if yql_query is None: return {} yql_url = baseurl + urlencode({'q': yql_query }) + "&format=json&lang=fr-FR" result = urlopen(yql_url).read() data = json.loads(result) res = makeWebhookResult(data) #météoopen elif req.get("result").get("action") == "openweather": baseurl = "api.openweathermap.org/data/2.5/weather?" owm_query = makeOwmQuery(req) #if owm_query is None: #return {} owm_url = baseurl + urlencode({ 'q': owm_query }) + "&lang=fr&APPID=8436a2c87fc4408d01d9f7f92e9759ca" result = urlopen(owm_url).read() data = json.loads(result) res = makeWebhookResultopen(data) #sheet exposant elif req.get("result").get("action") == "readsheet-exp": GsExp_query = makeGsExpQuery(req) client = SheetsuClient("https://sheetsu.com/apis/v1.0su/27ac2cb1ff16") data = client.search(sheet="Exposant", nom=GsExp_query) res = makeWebhookResultForSheetsExp(data) #sheet bus elif req.get("result").get("action") == "readsheet-bus": GsBus_query = makeGsBusQuery(req) client = SheetsuClient("https://sheetsu.com/apis/v1.0su/27ac2cb1ff16") data = client.search(sheet="Navette", date=GsBus_query) res = makeWebhookResultForSheetsBus(data) #sheet session elif req.get("result").get("action") == "readsheet-ses": GsSes_query = makeGsSesQuery(req) client = SheetsuClient("https://sheetsu.com/apis/v1.0su/27ac2cb1ff16") data = client.search(sheet="Conference", date=GsSes_query) res = makeWebhookResultForSheetsSes(data) #sheet conference elif req.get("result").get("action") == "readsheet-seshor": GsSesHor_query = makeGsSesHorQuery(req) client = SheetsuClient("https://sheetsu.com/apis/v1.0su/27ac2cb1ff16") data = client.search(sheet="Conference", Partner=GsSesHor_query) res = makeWebhookResultForSheetsSesHor(data) #sheetnow elif req.get("result").get("action") == "readsheet-ses-now": #GsSesNow_query = makeGsSesNowQuery(req) client = SheetsuClient("https://sheetsu.com/apis/v1.0su/27ac2cb1ff16") data = client.read(sheet="Conference") res = makeWebhookResultForSheetsSesNow(data) else: return {} return res
def processRequest(req): #météo if req.get("queryResult").get("action") == "yahooWeatherForecast": baseurl = "https://query.yahooapis.com/v1/public/yql?" yql_query = makeYqlQuery(req) if yql_query is None: return {} yql_url = baseurl + urlencode({'q': yql_query }) + "&format=json&lang=fr-FR" result = urlopen(yql_url).read() data = json.loads(result) res = makeWebhookResult(data) # #sheet exposant elif req.get("queryResult").get("action") == "readsheet-exp": GsExp_query = makeGsExpQuery(req) client = SheetsuClient("https://sheetsu.com/apis/v1.0su/27ac2cb1ff16") #à modifier: 'sheet="Exposant"' choisir la sheet correspondante data = client.search(sheet="Exposant", nom=GsExp_query) res = makeWebhookResultForSheetsExp(data) # #sheet bus elif req.get("queryResult").get("action") == "readsheet-bus": GsBus_query = makeGsBusQuery(req) client = SheetsuClient("https://sheetsu.com/apis/v1.0su/27ac2cb1ff16") #à modifier: 'sheet="Navette"' choisir la sheet correspondante data = client.search(sheet="Navette", date=GsBus_query) res = makeWebhookResultForSheetsBus(data) #sheet session elif req.get("queryResult").get("action") == "readsheet-ses": GsSes_query = makeGsSesQuery(req) client = SheetsuClient("https://sheetsu.com/apis/v1.0su/27ac2cb1ff16") #à modifier: 'sheet="Conference"' choisir la sheet correspondante data = client.search(sheet="Conference", date=GsSes_query) res = makeWebhookResultForSheetsSes(data) #sheet conference elif req.get("queryResult").get("action") == "readsheet-seshor": GsSesHor_query = makeGsSesHorQuery(req) client = SheetsuClient("https://sheetsu.com/apis/v1.0su/27ac2cb1ff16") #à modifier: 'sheet="Conference"' choisir la sheet correspondante data = client.search(sheet="Conference", Partner=GsSesHor_query) res = makeWebhookResultForSheetsSesHor(data) #sheetnow # elif req.get("queryResult").get("action")=="readsheet-ses-now": # #GsSesNow_query = makeGsSesNowQuery(req) # client = SheetsuClient("https://sheetsu.com/apis/v1.0su/27ac2cb1ff16") # data = client.read(sheet="Conference") # res = makeWebhookResultForSheetsSesNow(data) else: return {} return res
def test_search_success(self, mock): """Ensure that DELETE works properlly """ mock.return_value = MagicMock(status_code=200, content=json.dumps([ {'id': '1', 'name': 'Peter', 'score': '123'} ])) client = SheetsuClient(**self.kwargs) response = client.search(sheet="Sheet", limit=1, offset=1, ignore_case=True, name="peter") self.assertEqual(response, [ {'id': '1', 'name': 'Peter', 'score': '123'} ])
from sheetsu import SheetsuClient import json client = SheetsuClient("600798ca543a") output = client.search(sheet="Sheet1") print output with open('store.json', 'w') as outfile: json.dump(output, outfile) print "written"