new_pinsets.append(new_pinset)
            print "New pinset", today_u, "found."

    #Now, we update all previously existing pinsets and save the new ones
    am.connect('nextor_tarificador');
    sql = "INSERT INTO tarifica_pinset \
    (pinset_number) VALUES(%s)"
    totalRowsSaved = am.cursor.executemany(sql, new_pinsets)
    am.db.commit()
    print "----------------------------------------"
    print totalRowsSaved, "new pinsets saved."

if __name__ == "__main__":
    today = date.today()
    today = today - timedelta(days=1)
    cca = CallCostAssigner()
    dig = Digester()

    print "Digesting data from", today.strftime('%Y-%m-%d')

    #First we update all information on django's db:
    print "Updating Trunk Information..."
    updateTrunkInformation()
    print "Updating User Information..."
    updateUserInformation()
    print "Updating Pinset Information..."
    updatePinsetInformation()

    print "----------------------------------------------"
    print "Assigning costs..."
示例#2
0
    return am.db.close()

def resetBundleUsage():
    am = AsteriskMySQLManager()
    am.connect('nextor_tarificador')
    sql = "UPDATE tarifica_bundle SET tarifica_bundle.usage = %s"
    am.cursor.execute(sql, (0,))
    am.db.commit()
    return am.db.close()

# This file processes from january first's worth of data, using assignCallCost and Digester
# We go six months back... back in time!

today = date.today()
start = date(year = today.year, month=8, day=1)
cca = CallCostAssigner()
dig = Digester()
calls_saved = 0
calls_not_saved = 0
testRun = False

if len(sys.argv) > 1:
    if sys.argv[1] != '':
        #We try to create a new date
        start = datetime.strptime(sys.argv[1], "%Y-%m-%d").date()
        print start

if len(sys.argv) > 2:
    if sys.argv[2] == '--testrun':
        testRun = True