Exemplo n.º 1
0
def _send_to_idigi (data, filename, collection, content_type, secure=True):
    if data == None or filename == None:
        return False
        
    try:	
        host, token, path, port, securePort = _idigi._get_ws_parms()
		
        if secure == True:
            host = "%s:%d" % (host, securePort)
        else:
            host = "%s:%d" % (host, port)   
			
    except:
        host, token, path = _idigi._get_ws_parms()
        hostSplit = host.split(":")
        port = hostSplit[1]
		
    if host == None or host[0] == ":" or token == None or path == None or \
           port == None or port == 0:
        
        err = 10000
        msg = "Data Service not available, check Remote Management configuration"
        return False, err, msg

    if collection == None:
        fullPath = path
    else:
        fullPath = path + "/" + collection

    tout = 300 # TODO: Parameterize
    if secure == True:
        con = httplib.HTTPSConnection(host)
    else:
        con = httplib.HTTPConnection(host)

    con.putrequest('PUT', '%s/%s' % (fullPath, filename))

    con.putheader('Content-Type', content_type)
    clen = len(data)
    con.putheader('Content-Length', `clen`)
    con.putheader('Authorization', 'Basic %s' % token)
    con.endheaders()
    con.send(data)

    response = con.getresponse()
    errcode = response.status
    errmsg = response.reason
    headers = response.msg
    con.close()

    if errcode != 200 and errcode != 201:  
        return False, errcode, errmsg
    else:  
        return True, errcode, errmsg
Exemplo n.º 2
0
def _send_to_idigi (data, filename, collection, content_type, secure=True):
    if data == None or filename == None:
        return False
        
    try:	
        host, token, path, port, securePort = _idigi._get_ws_parms()
		
        if secure == True:
            host = "%s:%d" % (host, securePort)
        else:
            host = "%s:%d" % (host, port)   
			
    except:
        host, token, path = _idigi._get_ws_parms()
        hostSplit = host.split(":")
        port = hostSplit[1]
		
    if host == None or host[0] == ":" or token == None or path == None or \
           port == None or port == 0:
        
        err = 10000
        msg = "Data Service not available, check Remote Management configuration"
        return False, err, msg

    if collection == None:
        fullPath = path
    else:
        fullPath = path + "/" + collection

    tout = 300 # TODO: Parameterize
    if secure == True:
        con = httplib.HTTPSConnection(host)
    else:
        con = httplib.HTTPConnection(host)

    con.putrequest('PUT', '%s/%s' % (fullPath, filename))

    con.putheader('Content-Type', content_type)
    clen = len(data)
    con.putheader('Content-Length', `clen`)
    con.putheader('Authorization', 'Basic %s' % token)
    con.endheaders()
    con.send(data)

    response = con.getresponse()
    errcode = response.status
    errmsg = response.reason
    headers = response.msg
    con.close()

    if errcode != 200 and errcode != 201:  
        return False, errcode, errmsg
    else:  
        return True, errcode, errmsg
Exemplo n.º 3
0
def send_to_idigi(data,
                  filename,
                  collection=None,
                  content_type=None,
                  archive=False,
                  append=False,
                  timeout=None):
    host, token, path, port, securePort = cwm._get_ws_parms()

    webservice = httplib.HTTP(host, port)
    webservice.putrequest("PUT", "%s/%s" % (path, filename))
    webservice.putheader("Authorization", "Basic %s" % token)
    webservice.putheader("Content-type", "text/xml; charset=\"UTF-8\"")
    webservice.putheader("Content-length", "%d" % len(data))
    webservice.endheaders()
    webservice.send(data)

    # get the response
    statuscode, statusmessage, header = webservice.getreply()
    webservice.close()
    if statuscode != 200 and statuscode != 201:
        success = False
    else:
        success = True
    return success, statuscode, statusmessage
Exemplo n.º 4
0
def send_to_idigi(data, filename, collection=None, content_type=None, archive=False, append=False, timeout=None):
    host, token, path, port, securePort = cwm._get_ws_parms()

    webservice = httplib.HTTP(host, port)
    webservice.putrequest("PUT", "%s/%s" % (path, filename))
    webservice.putheader("Authorization", "Basic %s" % token)
    webservice.putheader("Content-type", 'text/xml; charset="UTF-8"')
    webservice.putheader("Content-length", "%d" % len(data))
    webservice.endheaders()
    webservice.send(data)

    # get the response
    statuscode, statusmessage, header = webservice.getreply()
    webservice.close()
    if statuscode != 200 and statuscode != 201:
        success = False
    else:
        success = True
    return success, statuscode, statusmessage
Exemplo n.º 5
0
def get_idigi_values():
    """\
        Used to return the current runtime Device Cloud values and parameters.
    """
    return _idigi._get_ws_parms()
Exemplo n.º 6
0
def get_idigi_values():
    """\
        Used to return the current runtime iDigi values and parameters.
    """
    return _idigi._get_ws_parms()