示例#1
0
def moveDevice(hid,ouid,nuid,did):
    unittype = 'device'
    utab = unitTables[unittype]
    ctab = capTables[unittype]
    if ouid == '':
      ouid = default_user
    if nuid == '':
      nuid = default_user
    if nuid == ouid:
      return(1,"SUCCESS")
    odigest = get_digest(hid,ouid,did)
    ndigest = get_digest(hid,nuid,did)
    npdigest = get_digest(hid,nuid)
    #cmd1 = "update %s set parentdigest = '%s' where capped is True and cap != 'Infinity' and digest = '%s'"%(ctab,npdigest,odigest)
    cmd1 = "update %s set parentdigest = '%s' where digest = '%s'"%(utab,npdigest,odigest)
    cmd2 = "update %s set digest = '%s' where digest = '%s'"%(utab,ndigest,odigest)
    prnt = 1 
    conn = sql.sqlconn()
    sql.run_insert_cmd("begin",conn=conn,prnt=prnt)
    for cmd in [cmd1,cmd2]:
      res = sql.run_insert_cmd(cmd,conn=conn,prnt=prnt)
      if res[0] == 0:
        sql.run_insert_cmd("rollback",conn=conn,prnt=prnt)
        return (0,"ERROR")
    sql.run_insert_cmd("commit",conn=conn,prnt=prnt)
    return (1,"SUCCESS")
示例#2
0
#!/usr/bin/env python
import os
import sys
import subprocess as sub
import gzip as gz
import time
import pgsql as sql

conn = sql.sqlconn()
traceroutearr = {}


def get_fields(line):
    skey = ''
    if '/>' in line:
        skey = '/>'
    else:
        skey = '>'

    try:
        line = line.split('<')[1]
    except:
        return None
    line = line.split(skey)[0]
    line = line.replace("'", "")
    line = line.replace('"', '')
    val = line.split()
    return val


def get_measurement_params(fids, vals, arr):
#!/usr/bin/env python
import os
import sys
import subprocess as sub
import gzip as gz
import time
import pgsql as sql
import bsdtr

conn = sql.sqlconn()
traceroutearr = {}
bsdtr.init()

def get_fields(line):
  skey = ''
  if '/>' in line:
    skey = '/>'
  else:
    skey = '>'

  try:
    line = line.split('<')[1]
  except:
    return None
  line = line.split(skey)[0]
  line = line.replace("'","")
  line = line.replace('"','')
  val = line.split()
  return val

def get_measurement_params(fids,vals,arr):