Beispiel #1
0
 def POST(self):
     cookie = web.cookies()[loggedInCookie]
     if len(cookie):
         i = web.input()
         print "[DBG] web.input() = %s" % (json.dumps(i),)
         print "[DBG] web.data() = %s" % (json.dumps(web.data()),)
         _amnt = i.amount
         _cat = i.category
         _desc = utils.allOrNone(i.description)
         _date = utils.timestampFromDate(i.date, False)
         print "[DBG] (amount, category, description, date) = (%s, %s, %s, %s)" % (_amnt, _cat, _desc, _date)
         self.m_worker.newExpense(amount = _amnt, category = _cat,
                 description = _desc, date = _date,
                 cookie = long(cookie))
     else:
         pass
     pass
Beispiel #2
0
SUBNET = '192.168.2.'
logPath = '/home/trafdata/net-acct.log'

#***************************************************

db = DATABASES['default']
conn = psycopg2.connect(('dbname = %s user = %s password = %s host = %s') % \
                        (db['NAME'], db['USER'], db['PASSWORD'], db['HOST']))
cur = conn.cursor()

if os.access(logPath, os.F_OK):
    os.rename(logPath, logPath + '.work')
    wfHandler = open(logPath + '.work', 'r')
    for line in wfHandler:
        line = line.split('\t')
        date = timestampFromDate(dateFromTimestamp(int(line[0])))
        srcIp = line[2]
        srcPort = int(line[3])
        dstIp = line[4]
        dstPort = int(line[5])
        byte = int(line[6])
        inByte = outByte = 0
        if SUBNET in srcIp:
            inByte = byte
            ip = srcIp
            port = dstPort
            flag = True
        elif SUBNET in dstIp:
            outByte = byte
            ip = dstIp
            port = srcPort
Beispiel #3
0
        catg = raw_input("bill category: ")
        uid = worker.userIdFromCookie(ck)
        if uid is None:
            sys.stderr.write("User for cookie %s not present" % ck)
            sys.exit(1)
        listify = lambda tags: ((tags is None or len(tags) == 0)
                and [[]] or [tags.split(",")])[0]
        tags = listify(raw_input("tags (csv list): "))
        desc = utils.allOrNone(raw_input("desc: "))
        members = listify(raw_input("participants: "))
        amounts = listify(raw_input("participants contributions: "))
        emails = listify(raw_input("emails: "))
        btype = raw_input("bill type [individual, shared, itemized]: ")
        tstmp = utils.timestamp(False)
        worker.newBill(userCookie = ck, amount = amnt, category = catg,
                date = tstmp, reportedBy = uid, reportedAt = tstmp,
                billType = btype, participants = members, tags = tags,
                description = desc, userAmounts = amounts,
                emails = emails)
    cont = raw_input("wanna see report (y/n): ")
    if cont == "y" or cont == "Y":
        date = raw_input("date (YYYYMMDD): ")
        category = utils.allOrNone(raw_input("category: "))
        print worker.reportRequest(userCookie = ck,
                startDate = utils.timestampFromDate(date, False),
                category = category)
    sys.stdout.write("Goodbye!\n")