#!/usr/bin/env python
#
# Autogenerated by Thrift Compiler (0.9.2)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
#  options string: py
#

import sys
import pprint
from urlparse import urlparse
from thrift.transport import TTransport
from thrift.transport import TSocket
from thrift.transport import TSSLSocket
from thrift.transport import THttpClient
from thrift.protocol import TBinaryProtocol

from ice import Ice
from ice.ttypes import *

if len(sys.argv) <= 1 or sys.argv[1] == '--help':
  print('')
  print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] function [arg1 [arg2...]]')
  print('')
  print('Functions:')
  print('  void ping()')
  print('  i32 status(i32 id)')
  print('  i32 SendMsg(eCategory Cat, eTelematics Tel,  eType,  sKey,  sValue)')
  print('  i32 SendMsgRaw(eCategory Cat, i32 SubCat,  eType,  sKey,  sValue)')
  print('  i32 OTA_RefreshUpdateList()')
  print('   OTA_GetUpdateList()')
  print('  string OTA_GetUpdateInfo(string sVersion)')
  print('  i32 OTA_UpdateInitiate(string sVersion)')
  print('  i32 OTA_UpdateInitiateType(string sVersion, eOTAType eType)')
  print('  i32 OTA_UpdateInitiateFeature(string sFeature)')
  print('  i32 OTA_Ack(string sessionID, eAckType eType)')
  print('  stUpdateStatus OTA_Status()')
  print('  i32 requestRemoteSupport(i32 width, i32 height)')
  print('  i32 stopRemoteSupport()')
  print('  stRemoteSupportStatus remoteSupportStatus()')
  print('  string getModemId()')
  print('  i32 getSignalStrength()')
  print('  bool getWanStatus()')
  print('  bool getRoamingStatus()')
  print('  i32 SetModemInfo(stCellularInfo sInfo)')
  print('  stCellularInfo GetModemInfo()')
  print('  i32 SetGPSInfo(stGPSInfo sInfo)')
  print('  stGPSInfo GetGPSInfo()')
  print('  bool getSlingshotConnectionStatus()')
  print('  string getSlingshotUUID()')
  print('  string getSlingshotOwner()')
  print('  i32 getSlingshotOwnerId()')
  print('  string getSlingshotName()')
  print('  i32 SetSlingshotName(string sName)')
  print('  string getSlingshotSystemName()')
  print('  string getEULAVersion()')
  print('  i32 acceptEULA(eEULAAcceptType eType)')
  print('   FT_GetRemoteFileList()')
  print('  i32 FT_UploadFile(stFileInfo sFile)')
  print('  i32 FT_DownloadFile(stDownloadFileInfo sFile)')
  print('  stFileInfo FT_CopyFile(string sFileID)')
  print('  i32 FT_Ack(string sFileID, eFTAckType eType)')
  print('  i32 FT_Acknowledge(string sFileID, eFTAckType eType, eFTErrorType eError)')
  print('  stFileTransferStatus FT_GetStatus(string sFileID)')
  print('   FT_GetActiveSessions()')
  print('   FT_GetHistoryTime(string sStartDate, string sEndDate)')
  print('   FT_GetHistoryIndex(i32 sStartIndex, i32 sEndIndex)')
  print('   SYS_GetInterfaceList()')
  print('   SYS_GetPeerList(string sInterface)')
  print('  i32 SYS_SetPeerList(string sInterface,  stDevices)')
  print('  i32 TEL_SendDTC(string sInterface, string sID,  stDTCs)')
  print('  i32 TEL_SendCAN(string sFilter,  stDevices)')
  print('  i32 TEL_SendGPS(stGPSInfo sGPSData)')
  print('  i32 TEL_SendRTK( stRTK)')
  print('  i32 TEL_SendMDM(stModemInfo sModemInfo)')
  print('  i32 TEL_SendGeneric(string sType,  eType,  sKey,  sValue)')
  print('  i32 TEL_SendGenericJSON(string sType, string sPayload)')
  print('   MGT_GetFeatureList()')
  print('  bool MGT_IsFeatureEnabled(eMGTFeature eFeature)')
  print('  stMGTStatus MGT_GetStatus()')
  print('  i32 MGT_SetConfig(stMGTCfg sCfg)')
  print('  stMGTCfg MGT_GetConfig()')
  print('  i32 MGT_ProvisionRequest(string sType)')
  print('   MGT_GetProvisionList()')
  print('  stProvision MGT_GetProvision(string sType)')
  print('   MGT_GetErrors(i32 index)')
  print('  string MGT_ServiceDiscoveryRequest(string sService, string sVersion)')
  print('  ServiceDiscoveryResult MGT_GetServiceDiscoveryResult(string sCorrelationId)')
  print('  stRTKInfo RTK_GetLockedSource()')
  print('   RTK_GetSources()')
  print('   JOB_GetList()')
  print('  stJobStatus JOB_GetStatus(string sGUID)')
  print('  i32 JOB_SendStatus(string sGUID, string sName, string sStatus)')
  print('  i32 JOB_Create(stJobCreate sJob)')
  print('  i32 JOB_CreateExt(stJobCreateExt sJob)')
  print('  i32 JOB_Join(string sGUID)')
  print('  i32 JOB_Leave(string sGUID, string sDataGUID)')
  print('  i32 JOB_RequestResources(string sGUID)')
  print('   JOB_GetResources(string sGUID)')
  print('  i32 JOB_SetMutableData(string sGUID,  points)')
  print('')
  sys.exit(0)

pp = pprint.PrettyPrinter(indent = 2)
host = 'localhost'
port = 9090
uri = ''
framed = False
ssl = False
http = False
argi = 1

if sys.argv[argi] == '-h':
  parts = sys.argv[argi+1].split(':')
  host = parts[0]
  if len(parts) > 1:
    port = int(parts[1])
  argi += 2

if sys.argv[argi] == '-u':
  url = urlparse(sys.argv[argi+1])
  parts = url[1].split(':')
  host = parts[0]
  if len(parts) > 1:
    port = int(parts[1])
  else:
    port = 80
  uri = url[2]
  if url[4]:
    uri += '?%s' % url[4]
  http = True
  argi += 2

if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
  framed = True
  argi += 1

if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl':
  ssl = True
  argi += 1

cmd = sys.argv[argi]
args = sys.argv[argi+1:]

if http:
  transport = THttpClient.THttpClient(host, port, uri)
else:
  socket = TSSLSocket.TSSLSocket(host, port, validate=False) if ssl else TSocket.TSocket(host, port)
  if framed:
    transport = TTransport.TFramedTransport(socket)
  else:
    transport = TTransport.TBufferedTransport(socket)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = Ice.Client(protocol)
transport.open()

if cmd == 'ping':
  if len(args) != 0:
    print('ping requires 0 args')
    sys.exit(1)
  pp.pprint(client.ping())

elif cmd == 'status':
  if len(args) != 1:
    print('status requires 1 args')
    sys.exit(1)
  pp.pprint(client.status(eval(args[0]),))

elif cmd == 'SendMsg':
  if len(args) != 5:
    print('SendMsg requires 5 args')
    sys.exit(1)
  pp.pprint(client.SendMsg(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))

elif cmd == 'SendMsgRaw':
  if len(args) != 5:
    print('SendMsgRaw requires 5 args')
    sys.exit(1)
  pp.pprint(client.SendMsgRaw(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))

elif cmd == 'OTA_RefreshUpdateList':
  if len(args) != 0:
    print('OTA_RefreshUpdateList requires 0 args')
    sys.exit(1)
  pp.pprint(client.OTA_RefreshUpdateList())

elif cmd == 'OTA_GetUpdateList':
  if len(args) != 0:
    print('OTA_GetUpdateList requires 0 args')
    sys.exit(1)
  pp.pprint(client.OTA_GetUpdateList())

elif cmd == 'OTA_GetUpdateInfo':
  if len(args) != 1:
    print('OTA_GetUpdateInfo requires 1 args')
    sys.exit(1)
  pp.pprint(client.OTA_GetUpdateInfo(args[0],))

elif cmd == 'OTA_UpdateInitiate':
  if len(args) != 1:
    print('OTA_UpdateInitiate requires 1 args')
    sys.exit(1)
  pp.pprint(client.OTA_UpdateInitiate(args[0],))

elif cmd == 'OTA_UpdateInitiateType':
  if len(args) != 2:
    print('OTA_UpdateInitiateType requires 2 args')
    sys.exit(1)
  pp.pprint(client.OTA_UpdateInitiateType(args[0],eval(args[1]),))

elif cmd == 'OTA_UpdateInitiateFeature':
  if len(args) != 1:
    print('OTA_UpdateInitiateFeature requires 1 args')
    sys.exit(1)
  pp.pprint(client.OTA_UpdateInitiateFeature(args[0],))

elif cmd == 'OTA_Ack':
  if len(args) != 2:
    print('OTA_Ack requires 2 args')
    sys.exit(1)
  pp.pprint(client.OTA_Ack(args[0],eval(args[1]),))

elif cmd == 'OTA_Status':
  if len(args) != 0:
    print('OTA_Status requires 0 args')
    sys.exit(1)
  pp.pprint(client.OTA_Status())

elif cmd == 'requestRemoteSupport':
  if len(args) != 2:
    print('requestRemoteSupport requires 2 args')
    sys.exit(1)
  pp.pprint(client.requestRemoteSupport(eval(args[0]),eval(args[1]),))

elif cmd == 'stopRemoteSupport':
  if len(args) != 0:
    print('stopRemoteSupport requires 0 args')
    sys.exit(1)
  pp.pprint(client.stopRemoteSupport())

elif cmd == 'remoteSupportStatus':
  if len(args) != 0:
    print('remoteSupportStatus requires 0 args')
    sys.exit(1)
  pp.pprint(client.remoteSupportStatus())

elif cmd == 'getModemId':
  if len(args) != 0:
    print('getModemId requires 0 args')
    sys.exit(1)
  pp.pprint(client.getModemId())

elif cmd == 'getSignalStrength':
  if len(args) != 0:
    print('getSignalStrength requires 0 args')
    sys.exit(1)
  pp.pprint(client.getSignalStrength())

elif cmd == 'getWanStatus':
  if len(args) != 0:
    print('getWanStatus requires 0 args')
    sys.exit(1)
  pp.pprint(client.getWanStatus())

elif cmd == 'getRoamingStatus':
  if len(args) != 0:
    print('getRoamingStatus requires 0 args')
    sys.exit(1)
  pp.pprint(client.getRoamingStatus())

elif cmd == 'SetModemInfo':
  if len(args) != 1:
    print('SetModemInfo requires 1 args')
    sys.exit(1)
  pp.pprint(client.SetModemInfo(eval(args[0]),))

elif cmd == 'GetModemInfo':
  if len(args) != 0:
    print('GetModemInfo requires 0 args')
    sys.exit(1)
  pp.pprint(client.GetModemInfo())

elif cmd == 'SetGPSInfo':
  if len(args) != 1:
    print('SetGPSInfo requires 1 args')
    sys.exit(1)
  pp.pprint(client.SetGPSInfo(eval(args[0]),))

elif cmd == 'GetGPSInfo':
  if len(args) != 0:
    print('GetGPSInfo requires 0 args')
    sys.exit(1)
  pp.pprint(client.GetGPSInfo())

elif cmd == 'getSlingshotConnectionStatus':
  if len(args) != 0:
    print('getSlingshotConnectionStatus requires 0 args')
    sys.exit(1)
  pp.pprint(client.getSlingshotConnectionStatus())

elif cmd == 'getSlingshotUUID':
  if len(args) != 0:
    print('getSlingshotUUID requires 0 args')
    sys.exit(1)
  pp.pprint(client.getSlingshotUUID())

elif cmd == 'getSlingshotOwner':
  if len(args) != 0:
    print('getSlingshotOwner requires 0 args')
    sys.exit(1)
  pp.pprint(client.getSlingshotOwner())

elif cmd == 'getSlingshotOwnerId':
  if len(args) != 0:
    print('getSlingshotOwnerId requires 0 args')
    sys.exit(1)
  pp.pprint(client.getSlingshotOwnerId())

elif cmd == 'getSlingshotName':
  if len(args) != 0:
    print('getSlingshotName requires 0 args')
    sys.exit(1)
  pp.pprint(client.getSlingshotName())

elif cmd == 'SetSlingshotName':
  if len(args) != 1:
    print('SetSlingshotName requires 1 args')
    sys.exit(1)
  pp.pprint(client.SetSlingshotName(args[0],))

elif cmd == 'getSlingshotSystemName':
  if len(args) != 0:
    print('getSlingshotSystemName requires 0 args')
    sys.exit(1)
  pp.pprint(client.getSlingshotSystemName())

elif cmd == 'getEULAVersion':
  if len(args) != 0:
    print('getEULAVersion requires 0 args')
    sys.exit(1)
  pp.pprint(client.getEULAVersion())

elif cmd == 'acceptEULA':
  if len(args) != 1:
    print('acceptEULA requires 1 args')
    sys.exit(1)
  pp.pprint(client.acceptEULA(eval(args[0]),))

elif cmd == 'FT_GetRemoteFileList':
  if len(args) != 0:
    print('FT_GetRemoteFileList requires 0 args')
    sys.exit(1)
  pp.pprint(client.FT_GetRemoteFileList())

elif cmd == 'FT_UploadFile':
  if len(args) != 1:
    print('FT_UploadFile requires 1 args')
    sys.exit(1)
  pp.pprint(client.FT_UploadFile(eval(args[0]),))

elif cmd == 'FT_DownloadFile':
  if len(args) != 1:
    print('FT_DownloadFile requires 1 args')
    sys.exit(1)
  pp.pprint(client.FT_DownloadFile(eval(args[0]),))

elif cmd == 'FT_CopyFile':
  if len(args) != 1:
    print('FT_CopyFile requires 1 args')
    sys.exit(1)
  pp.pprint(client.FT_CopyFile(args[0],))

elif cmd == 'FT_Ack':
  if len(args) != 2:
    print('FT_Ack requires 2 args')
    sys.exit(1)
  pp.pprint(client.FT_Ack(args[0],eval(args[1]),))

elif cmd == 'FT_Acknowledge':
  if len(args) != 3:
    print('FT_Acknowledge requires 3 args')
    sys.exit(1)
  pp.pprint(client.FT_Acknowledge(args[0],eval(args[1]),eval(args[2]),))

elif cmd == 'FT_GetStatus':
  if len(args) != 1:
    print('FT_GetStatus requires 1 args')
    sys.exit(1)
  pp.pprint(client.FT_GetStatus(args[0],))

elif cmd == 'FT_GetActiveSessions':
  if len(args) != 0:
    print('FT_GetActiveSessions requires 0 args')
    sys.exit(1)
  pp.pprint(client.FT_GetActiveSessions())

elif cmd == 'FT_GetHistoryTime':
  if len(args) != 2:
    print('FT_GetHistoryTime requires 2 args')
    sys.exit(1)
  pp.pprint(client.FT_GetHistoryTime(args[0],args[1],))

elif cmd == 'FT_GetHistoryIndex':
  if len(args) != 2:
    print('FT_GetHistoryIndex requires 2 args')
    sys.exit(1)
  pp.pprint(client.FT_GetHistoryIndex(eval(args[0]),eval(args[1]),))

elif cmd == 'SYS_GetInterfaceList':
  if len(args) != 0:
    print('SYS_GetInterfaceList requires 0 args')
    sys.exit(1)
  pp.pprint(client.SYS_GetInterfaceList())

elif cmd == 'SYS_GetPeerList':
  if len(args) != 1:
    print('SYS_GetPeerList requires 1 args')
    sys.exit(1)
  pp.pprint(client.SYS_GetPeerList(args[0],))

elif cmd == 'SYS_SetPeerList':
  if len(args) != 2:
    print('SYS_SetPeerList requires 2 args')
    sys.exit(1)
  pp.pprint(client.SYS_SetPeerList(args[0],eval(args[1]),))

elif cmd == 'TEL_SendDTC':
  if len(args) != 3:
    print('TEL_SendDTC requires 3 args')
    sys.exit(1)
  pp.pprint(client.TEL_SendDTC(args[0],args[1],eval(args[2]),))

elif cmd == 'TEL_SendCAN':
  if len(args) != 2:
    print('TEL_SendCAN requires 2 args')
    sys.exit(1)
  pp.pprint(client.TEL_SendCAN(args[0],eval(args[1]),))

elif cmd == 'TEL_SendGPS':
  if len(args) != 1:
    print('TEL_SendGPS requires 1 args')
    sys.exit(1)
  pp.pprint(client.TEL_SendGPS(eval(args[0]),))

elif cmd == 'TEL_SendRTK':
  if len(args) != 1:
    print('TEL_SendRTK requires 1 args')
    sys.exit(1)
  pp.pprint(client.TEL_SendRTK(eval(args[0]),))

elif cmd == 'TEL_SendMDM':
  if len(args) != 1:
    print('TEL_SendMDM requires 1 args')
    sys.exit(1)
  pp.pprint(client.TEL_SendMDM(eval(args[0]),))

elif cmd == 'TEL_SendGeneric':
  if len(args) != 4:
    print('TEL_SendGeneric requires 4 args')
    sys.exit(1)
  pp.pprint(client.TEL_SendGeneric(args[0],eval(args[1]),eval(args[2]),eval(args[3]),))

elif cmd == 'TEL_SendGenericJSON':
  if len(args) != 2:
    print('TEL_SendGenericJSON requires 2 args')
    sys.exit(1)
  pp.pprint(client.TEL_SendGenericJSON(args[0],args[1],))

elif cmd == 'MGT_GetFeatureList':
  if len(args) != 0:
    print('MGT_GetFeatureList requires 0 args')
    sys.exit(1)
  pp.pprint(client.MGT_GetFeatureList())

elif cmd == 'MGT_IsFeatureEnabled':
  if len(args) != 1:
    print('MGT_IsFeatureEnabled requires 1 args')
    sys.exit(1)
  pp.pprint(client.MGT_IsFeatureEnabled(eval(args[0]),))

elif cmd == 'MGT_GetStatus':
  if len(args) != 0:
    print('MGT_GetStatus requires 0 args')
    sys.exit(1)
  pp.pprint(client.MGT_GetStatus())

elif cmd == 'MGT_SetConfig':
  if len(args) != 1:
    print('MGT_SetConfig requires 1 args')
    sys.exit(1)
  pp.pprint(client.MGT_SetConfig(eval(args[0]),))

elif cmd == 'MGT_GetConfig':
  if len(args) != 0:
    print('MGT_GetConfig requires 0 args')
    sys.exit(1)
  pp.pprint(client.MGT_GetConfig())

elif cmd == 'MGT_ProvisionRequest':
  if len(args) != 1:
    print('MGT_ProvisionRequest requires 1 args')
    sys.exit(1)
  pp.pprint(client.MGT_ProvisionRequest(args[0],))

elif cmd == 'MGT_GetProvisionList':
  if len(args) != 0:
    print('MGT_GetProvisionList requires 0 args')
    sys.exit(1)
  pp.pprint(client.MGT_GetProvisionList())

elif cmd == 'MGT_GetProvision':
  if len(args) != 1:
    print('MGT_GetProvision requires 1 args')
    sys.exit(1)
  pp.pprint(client.MGT_GetProvision(args[0],))

elif cmd == 'MGT_GetErrors':
  if len(args) != 1:
    print('MGT_GetErrors requires 1 args')
    sys.exit(1)
  pp.pprint(client.MGT_GetErrors(eval(args[0]),))

elif cmd == 'MGT_ServiceDiscoveryRequest':
  if len(args) != 2:
    print('MGT_ServiceDiscoveryRequest requires 2 args')
    sys.exit(1)
  pp.pprint(client.MGT_ServiceDiscoveryRequest(args[0],args[1],))

elif cmd == 'MGT_GetServiceDiscoveryResult':
  if len(args) != 1:
    print('MGT_GetServiceDiscoveryResult requires 1 args')
    sys.exit(1)
  pp.pprint(client.MGT_GetServiceDiscoveryResult(args[0],))

elif cmd == 'RTK_GetLockedSource':
  if len(args) != 0:
    print('RTK_GetLockedSource requires 0 args')
    sys.exit(1)
  pp.pprint(client.RTK_GetLockedSource())

elif cmd == 'RTK_GetSources':
  if len(args) != 0:
    print('RTK_GetSources requires 0 args')
    sys.exit(1)
  pp.pprint(client.RTK_GetSources())

elif cmd == 'JOB_GetList':
  if len(args) != 0:
    print('JOB_GetList requires 0 args')
    sys.exit(1)
  pp.pprint(client.JOB_GetList())

elif cmd == 'JOB_GetStatus':
  if len(args) != 1:
    print('JOB_GetStatus requires 1 args')
    sys.exit(1)
  pp.pprint(client.JOB_GetStatus(args[0],))

elif cmd == 'JOB_SendStatus':
  if len(args) != 3:
    print('JOB_SendStatus requires 3 args')
    sys.exit(1)
  pp.pprint(client.JOB_SendStatus(args[0],args[1],args[2],))

elif cmd == 'JOB_Create':
  if len(args) != 1:
    print('JOB_Create requires 1 args')
    sys.exit(1)
  pp.pprint(client.JOB_Create(eval(args[0]),))

elif cmd == 'JOB_CreateExt':
  if len(args) != 1:
    print('JOB_CreateExt requires 1 args')
    sys.exit(1)
  pp.pprint(client.JOB_CreateExt(eval(args[0]),))

elif cmd == 'JOB_Join':
  if len(args) != 1:
    print('JOB_Join requires 1 args')
    sys.exit(1)
  pp.pprint(client.JOB_Join(args[0],))

elif cmd == 'JOB_Leave':
  if len(args) != 2:
    print('JOB_Leave requires 2 args')
    sys.exit(1)
  pp.pprint(client.JOB_Leave(args[0],args[1],))

elif cmd == 'JOB_RequestResources':
  if len(args) != 1:
    print('JOB_RequestResources requires 1 args')
    sys.exit(1)
  pp.pprint(client.JOB_RequestResources(args[0],))

elif cmd == 'JOB_GetResources':
  if len(args) != 1:
    print('JOB_GetResources requires 1 args')
    sys.exit(1)
  pp.pprint(client.JOB_GetResources(args[0],))

elif cmd == 'JOB_SetMutableData':
  if len(args) != 2:
    print('JOB_SetMutableData requires 2 args')
    sys.exit(1)
  pp.pprint(client.JOB_SetMutableData(args[0],eval(args[1]),))

else:
  print('Unrecognized method %s' % cmd)
  sys.exit(1)

transport.close()
