예제 #1
0
def transport():
    verify_useragent()
    raw = urllib.unquote(request.get_cookie(cookie_param_name, ''))
    if not raw: return 'no client data found'
    data = decrypt(raw)
    ret = invoke_service(data)
    ciphertext = encrypt(ret)
    # obfuscate data to js file
    body = copy(js_template)
    ciphers = splitn(ciphertext, len(placeholder))
    for i in range(len(placeholder)):
        body = body.replace(placeholder[i], '"%s"' % ciphers[i], 1)
    return body + '//%s' % md5digest(ciphertext)
예제 #2
0
def send_and_recv(buf):
    data = encrypt(buf)
    print 'send data length', len(data)
    cookies = {cookie_param_name: urllib.quote(data)}
    response = http_request('GET',
                            urlparse.urljoin(server_url, route_to_transport),
                            cookies=cookies)
    ciphers = re.findall('"(.*?)"', response)
    ciphertext = ''.join(ciphers)
    digest = md5digest(ciphertext)
    if response[-len(digest):] != digest:
        print 'recv data digest error!'
        return ''
    print 'recv data length', len(ciphertext)
    return decrypt(ciphertext)
예제 #3
0
def make_report(client):
    


if __name__ == "__main__":
    
    settings, node_id_lst = readsettings('settings.yaml')
    host = settings['influxdb']['host']
    port = settings['influxdb']['port']
    username = settings['influxdb']['username']
    password = encrypt(settings['influxdb']['password'])
    mydb = settings['influxdb']['mydb']

    client = InfluxDBClient(host=host, port=port,
                            username=username, password=password)

    listdb = client.get_list_database()
    listdb = [i['name'] for i in listdb]
    print(listdb)
    if mydb not in listdb:
        print('В influxdb нет БД {}'.format(mydb))
    else:
        client.switch_database(mydb)
        make_report(client)
예제 #4
0
        client_db.write_points(json_body)


#        print('Write point {} to db'.format(node.nodeid.to_string()))
#        print('________________________________\n')

#    def event_notification(self, event):
#        print("Python: New event", event)

if __name__ == "__main__":

    settings, nodes = readsettings('settings.yaml')
    # Set OPC UA server param
    url = settings['opcua_server']['url']
    ua_username = settings['opcua_server']['username']
    ua_password = encrypt(settings['opcua_server']['password'])
    ua_period = settings['opcua_server']['period_subsription']
    # Set inflaxdb param
    host = settings['influxdb']['host']
    port = settings['influxdb']['port']
    username = settings['influxdb']['username']
    password = encrypt(settings['influxdb']['password'])
    mydb = settings['influxdb']['mydb']
    #    username = settings['server_opcua']['username']
    #    psw = settings['server_opcua']['password'].encode()
    #    password = base64.b64decode(psw).decode()

    myvar = []

    client_db = InfluxDBClient(host=host,
                               port=port,
예제 #5
0
# -*- coding: utf-8 -*-
from influxdb import InfluxDBClient
from datetime import datetime
from settings import readsettings, encrypt

settings, node_id_lst = readsettings('settings.yaml')
host = settings['influxdb']['host']
port = settings['influxdb']['port']
username = settings['influxdb']['username']
password = encrypt(settings['influxdb']['password'])
mydb = settings['influxdb']['mydb']

client = InfluxDBClient(host=host,
                        port=port,
                        username=username,
                        password=password)

listdb = client.get_list_database()
print(listdb)
if mydb not in listdb:
    client.create_database(mydb)
client.switch_database(mydb)
now = datetime.now()
now = now.strftime("%Y-%m-%dT%H:%M:%S.%f")

json_body = [{
    "measurement": "power",
    "tags": {
        "station": "ST01",
        "blok": "01"
    },