def add_film_info(rj): result = None ext_oid = None if 'externalOrderId' in rj: conv = MySQLConverter() ext_oid = rj['externalOrderId'] success_url = conv.escape(rj.get('successUrl', None)) cancel_url = conv.escape(rj.get('cancelUrl', None)) db = db_connect() try: if not ext_oid: result = db_query(db, 'insert into vidimax (film_id, type, name, price) values ({film_id}, "{type}", "{name}", {price});'\ .format(film_id=rj['id'], type=rj['type'], name=rj['name'], price=int(int(rj['price'])/100)), commit=True, lastrow=True) else: query = 'insert into vidimax values (null, null, "{external_oid}", {film_id}, "{type}", "{name}", {price}, '.format( external_oid=ext_oid, film_id=rj['id'], type=rj['type'], name=rj['name'], price=int(int(rj['price'])/100) ) if success_url: query += '"{0}", '.format(success_url) else: query += 'null, ' if cancel_url: query += '"{0}");'.format(cancel_url) else: query += 'null);' result = db_query(db, query, commit=True, lastrow=True) except Exception as e: print e pass finally: db_disconnect(db) return result
def start_session(order_id): db = db_connect() db_query(db, 'update orders set stop_time=null, start_time=now(), ' 'state_id=0 ' 'where id=%d'%(order_id), fetch=False, commit=True ) db_disconnect(db)
def update_client_info(db, client_info, logout): result = client_info if not logout: pprint(client_info) res = db_query(db, 'select id from client_info where client_id=%d and mac="%s" and client_orders_id=%d;' %(client_info['client_id'], client_info['mac'], client_info['order_id']) ) if not res: # new client device if add_device_counter(db, client_info['order_id']): add_client_info(db, client_info) else: return None else: db_query(db, 'update client_info set ip="%s", lang="%s", update_time=now(), client_orders_id=%d where id=%d;' %(client_info['ip'], client_info['lang'], client_info['order_id'], res[0]), fetch=False, commit=True) query = 'update orders set ' if not started(db, client_info['order_id']): if not began(db, client_info['order_id']): query += 'begin_time=now(), ' query += 'start_time=now(), ' query += 'state_id=0 where id=%d'%(client_info['order_id']) db_query(db, query, fetch=False, commit=True) elif started(db, client_info['order_id']): stop_session(order_id, by_user=True) return result
def add_client_order(db, client_id, order_id): [ ord_id ] = db_query(db, 'select id from orders where order_id="%s";'%(order_id)) [ cnt ] = db_query(db, 'select count(*) from client_orders where client_id=%d and order_id=%d;'%(client_id, ord_id)) if cnt != 1: client_order_id = db_query(db, 'insert into client_orders (client_id, order_id) values (%d, %d);' %(client_id, ord_id), commit=True, fetch=False, lastrow=True ) return client_order_id
def add_device_counter(db, order_id): print 'add_device_counter', order_id ( current, ) = db_query(db, 'select dev_count from orders where id=%s'%(order_id)) result = True if current < 2: # hardcode db_query(db, 'update orders set dev_count = dev_count + 1 where id=%d'%(order_id), fetch=False, commit=True) result = True return result
def end_session(order_id): db = db_connect() db_query(db, 'update orders set stop_time=null, end_time=now(), state_id=3, ' 'session_time = sec_to_time(unix_timestamp() - unix_timestamp(start_time) + time_to_sec(session_time)), ' 'start_time=null ' 'where id=%d'%(order_id), fetch=False, commit=True ) unauth_user(db, order_id) db_disconnect(db)
def stop_session(order_id, by_user=False): if by_user: state_id = 1 else: state_id = 2 db = db_connect() db_query(db, 'update orders set stop_time = now(), ' 'state_id = %d, ' 'session_time = sec_to_time(unix_timestamp() - unix_timestamp(start_time) + time_to_sec(session_time)),' 'start_time = null' 'where id=%d'%(state_id, order_id), fetch=False, commit=True ) db_disconnect(db)
def new_code(): db = db_connect() generated = False while not generated: try: code = gen_code() db_query(db, 'insert into codes (key_value, used) values ("%s", 1);'%(code), commit=True, fetch=False) generated = True except: pass db_disconnect(db) return code
def save_taxi_order(data): print 'save_taxi_order:' print data db = db_connect() query = '''insert into taxi values ( 0, now(), "%(direction)s", "%(ip)s", "%(mac)s", "%(vgt_name)s", "%(vgt_phone)s", "%(vgt_email)s", "%(train)s", "%(vgt_from)s", "%(vgt_dest)s", "%(vgt_ctype)s", %(vgt_cprice)s, "%(vgt_data)s", "%(vgt_add)s", "%(vgt_add2)s", "%(vgt_tab)s", "%(vgt_comment)s", %(accept_offer)s );'''%data print query db_query(db, query, commit=True, fetch=False) db_disconnect(db) pass
def refund_payment(payment_info): db = db_connect() result = False pprint(payment_info) try: db_query(db, 'update orders set refund_id="%s", end_time=now(), refund_time="%s", state_id=4 where order_id="%s";' %(payment_info['refund_id'], payment_info['date'], payment_info['order_id']), commit=True, fetch=False) order_id=int(payment_info['order_id'][8:]) unauth_user(db, order_id) result = True except Exception as e: print e db_disconnect(db) return result
def get_active_sessions(): db = db_connect() lines = db_query(db, 'select ords.id, ords.direction, tariff_id, ords.start_time, ords.session_time, ' 'ords.client_films_id, tar.duration, ords.state_id from orders ords ' 'left join tariffs tar on tariff_id = tar.id ' 'where start_time is not null and state_id=0;', full=True ) result = {} if lines != []: for ( order_id, direction, tariff_id, start_time, session_time, is_film, dur, state_id ) in lines: print order_id, direction, dur duration = dur if direction and not is_film: duration = tariffs.get_duration(direction, tariff_id) # else: # duration = tariffs.get_direction_trip_duration(direction) result[str(order_id)] = { 'start_time' : start_time, 'session_time' : session_time, 'duration' : duration, 'state' : state_id } db_disconnect(db) return result
def verify_user(usrname, passwd): db = db_connect() result = True if not db_query(db, 'select id from users where user="******" and passwd=password("%s");'%(usrname, passwd)): result = False db_disconnect(db) return result
def delete(request): # if this is a POST request we need to process the form data if request.method == 'POST': # create a form instance and populate it with data from the request: form = deleteCompanyData(request.POST) # check whether it's valid: if form.is_valid(): # process the data in form.cleaned_data as required # ... # redirect to a new URL: # return HttpResponseRedirect('/index/') company = form.cleaned_data['company'] date = form.cleaned_data['date'] data = [] table = 'invest_sharePrice' path = '/home/website/website/mysite/db.sqlite3' db_delete(path, table, company, date) company_list = sharePrice.objects.all() # time.strftime('%Y-%m-%d', time.strptime("30 Nov 17", "%d %b %y")) data = serializers.serialize("json", company_list) companylist = db_query('/home/website/website/mysite/db.sqlite3', 'invest_sharePrice', "*") context = { #'company_list': json.dumps(company_list), 'company_list': data, 'companylist': companylist, } return render(request, 'invest/index.html', context) # if a GET (or any other method) we'll create a blank form else: form = deleteCompanyData() return render(request, 'invest/index.html', {'form': form})
def add_client_phone(db, ph): phone = get_phone(ph) return db_query(db, 'insert into clients set phone = ' 'case substr("%s",1,1) when "+" then "%s" ' 'when "8" then concat("+7",substr("%s",2)) ' 'when "9" then concat("+7","%s") ' 'else concat("+","%s") end;'%(phone, phone, phone, phone, phone), commit=True, fetch=False, lastrow=True)
def get_stats(begin, end): db = db_connect() now = datetime.datetime.now() datefmt = '%Y-%m-%d %H:%M:%S' begin_str = get_time(begin) or now.strftime('%Y-%m-%d 00:00:00') # hardcode end_str = get_time(end) or now.strftime(datefmt) query = 'select order_id, phone, code, price, price*0.10, payment_time, refund_time \ from orders o left join clients c on o.client_id=c.id \ left join tariffs.tariffs_tariff t on o.tariff_id=t.id \ where partner_id=1 and payment_time between "%s" and "%s"'%(begin_str, end_str) # hardcode res = db_query(db, query, full=True) db_disconnect(db) result = { 'Statistics' : [] } if res: for (oid, phone, code, price, fee, p_time, r_time) in res: tmp = { 'OrderID' : oid, 'Phone' : phone, 'Code' : code, 'Price' : int(price), 'Fee' : float(fee), 'PaymentTime' : p_time.strftime(datefmt) } if r_time: tmp['RefundTime'] = r_time.strftime(datefmt) result['Statistics'].append(tmp) return result
def get_code_by_billnumber(direction, ip, order, billnumber): result = {} res = None try: mac = get_mac(ip).replace(':','') if mac == '0'*12: raise ValueError('No MAC address for %s'%(ip)) db = db_connect() res = db_query(db, "select o.code from orders o " "where o.payment_time is not null and o.code <> '' and o.end_time is null and o.state_id <> 3 " # hardcode "and o.dev_count < 2 and o.direction='%s' and o.billnumber='%s' and o.first_mac=x'%s' and o.order_id='%s'" %(direction, billnumber, mac, order), ) except Exception as e: print e if not res: r = False code = None else: r = True code = res[0] result = { 'Code': code, 'Result': r } return result
def get_user_subscriptions(ip, ua): def get_subs_list(db, client_id): subs = [] res = db_query(db, 'select order_id, client_films_id, first_ip, direction \ from orders where client_id=%s and new_model=1 and state_id=0;'%(client_id), full=True) if res: for [ order_id, film_id, first_ip, direction ] in res: subs_info = get_subs_info(db, film_id, (first_ip, direction)) if subs_info not in subs: subs.append(subs_info) return subs pprint('get_user_subscriptions:') pprint(ip) pprint(ua) result = {} mac = get_mac(ip) db = db_connect() vip_client = is_vip_client(db, ip, mac) if vip_client: return { "VIP" : True } client_ids = db_query(db, 'select client_id as id from client_info where ip="%s" and mac="%s" group by client_id'%(ip, mac), full=True) if client_ids: print 'client found', client_ids result['UserID'] = client_ids[0][0] # in every way result['Subscriptions'] = [] if len(client_ids) > 1: print "f*****g f**k! this should not have happened but happened" for client in client_ids: result['Subscriptions'] += get_subs_list(db, client) db_disconnect(db) pprint(result) return result
def get_subs_info(db, video_id, train_info=None): def get_train_id(train_info): (ip, direction) = train_info num = '' if ip[:5] != '10.10': # hardcode here and below num = ip.replace('.', '-') else: num = '{0:03}'.format(int(ip.split('.')[2])/2 + 1) return '/'.join((num, direction.lower())) result = {} res = db_query(db, 'select v.film_id, v.type, v.name, v.price*100, o.order_id, v.external_order_id from vidimax v \ left join orders o on v.order_id = o.id where v.id={id};'.format(id=video_id)) if res: result = { 'id': res[0], 'type': res[1], 'name': res[2], 'price': res[3], 'orderId': res[4] } if res[5]: result['externalOrderId'] = res[5] if train_info: result['trainId'] = get_train_id(train_info) return result
def get_code(order_id): result = None db = db_connect() res = db_query(db, 'select code from orders where order_id="%s"'%(order_id)) db_disconnect(db) if res: [ result ] = res return result
def add_film_watch(request_json): result = False pprint(request_json) db = db_connect() ip = request_json['IPAddress'] mac = get_mac(ip) film_id = request_json['FilmID'] name = request_json['Name'] user_id = request_json.get('UserID', '0') user_agent = request_json.get('UserAgent', '') db_query(db, 'insert into watches (ip, mac, film_id, name, ua, user_id) values ("%s", "%s", %s, "%s", "%s", %s);' %(ip, mac, film_id, name, user_agent, user_id), commit=True, fetch=False ) result = True db_disconnect(db) return { "Result" : result }
def get_phones_to_sms(): db = db_connect() result = db_query(db, 'select ords.id, cl.phone, ords.code from orders ords left join clients cl on cl.id = client_id ' 'where (sms_sent = 0 or (sms_sent = 1 and unix_timestamp(now()) - unix_timestamp(payment_time) > 600)) ' 'and code <> "" order by payment_time;', full=True, quiet=True ) db_disconnect(db) return result
def get_shopid_by_orderid(order_id): result = {} db = db_connect() res = db_query(db, 'select s.shop from orders o left join shops s on s.id = o.shop_id where o.order_id = "%s"'%(order_id)) if res: result['ShopID'] = res[0] db_disconnect(db) return result
def unauth_user(db, order_id): res = db_query(db, 'select ip from client_info where client_orders_id=%s'%(order_id), full=True) for line in res: ip = line[0] attempts = 100 # hardcode while not deny_client(ip) and attempts > 0: time.sleep(10) attempts -= 1
def get_tariff(db, service, tariff, film_id, new_model=False): serv = service.upper() tar = tariff.upper() if not film_id: if tar in ['ONEHOUR', 'ONEDAY']: return db_query(db, 'select id, price from tariffs where service="%s" and type="%s";'%(serv, tar)) else: res = tariffs.get_tariff(serv, tar) if res: return res else: return tariffs.get_tariff(serv, '1HOUR') #hardcode elif tariff.upper() == 'FILM': query = 'select t.id, f.price from tariffs t left join films f on f.id = %s where service="%s" and type="%s";' if new_model: query = 'select id, (select price from vidimax where id=%s) from tariffs where service="%s" and type="%s";' return db_query(db, query%(film_id, 'VIDEOSVC', 'FILM'))
def get_filmid_by_orderid(order_id): result = {} if order_id[:8] == 'VIDEOSVC': db = db_connect() res = db_query(db, 'select client_films_id from orders where order_id="%s"'%(order_id)) if res: result['FilmID'] = res[0] db.close() return result
def get_train_direction(train): db = db_connect() query = 'select abbr from trains where number="%s"'%train res = db_query(db, query) db_disconnect(db) result = {} if res: result['Direction'] = res[0] return result
def get_subs_list(db, client_id): subs = [] res = db_query(db, 'select order_id, client_films_id, first_ip, direction \ from orders where client_id=%s and new_model=1 and state_id=0;'%(client_id), full=True) if res: for [ order_id, film_id, first_ip, direction ] in res: subs_info = get_subs_info(db, film_id, (first_ip, direction)) if subs_info not in subs: subs.append(subs_info) return subs
def get_client_by_phone(db, ph): phone = get_phone(ph) res = db_query(db, 'select id from clients where phone = ' 'case substr("%s",1,1) when "+" then "%s" ' 'when "8" then concat("+7",substr("%s",2)) ' 'when "9" then concat("+7","%s") ' 'else concat("+","%s") end;'%(phone, phone, phone, phone, phone), full=True) if res == []: return None return res[0][0]
def dataoperation(request): company_list = sharePrice.objects.all() # time.strftime('%Y-%m-%d', time.strptime("30 Nov 17", "%d %b %y")) data = serializers.serialize("json", company_list) companylist = db_query('/home/website/website/mysite/db.sqlite3', 'invest_sharePrice', "*") context = { #'company_list': json.dumps(company_list), 'company_list': data, 'companylist': companylist, } return render(request, 'invest/data.html', context)
def find_code(db, code): res = db_query(db, 'select id, client_id, tariff_id from orders where code="%s" and payment_time<>null and end_time=null;'%(code)) if not res: return None [ order_id, client_id, tariff_id ] = res result = { 'order_id' : order_id, 'client_id' : client_id, 'tariff_id' : tariff_id } return result
def update_order(payment_info): db = db_connect() result = False pprint(payment_info) client_id = get_client_by_phone(db, payment_info['phone']) if not client_id: client_id = add_client_phone(db, payment_info['phone']) code = payment_info['approval_code'] if check_order(db, payment_info): if not code: code = new_code() client_order_id = add_client_order(db, client_id, payment_info['order_id']) db_query(db, 'update orders set billnumber="%s", client_id=%d, payment_time="%s", code="%s" where order_id="%s";' %(payment_info['uni_billnumber'], client_id, payment_info['date'], code, payment_info['order_id']), commit=True, fetch=False) result = True if not settings.testing: send_sms(payment_info['phone'], code) sms_sent(payment_info['order_id']) db_disconnect(db) return result
def is_scratch_code(db, code): result = None if match_code(code) and len(code) == settings.scratch_length: res = db_query(db, 'select service, type, price from tariffs ' 'where id = (select tariff_id from codes where key_value="%s" and serial is not null and not used) ' 'and (select id from orders where code="%s") is null;'%(code, code) ) if res: result = { 'service' : res[0], 'tariff' : res[1], 'sum' : res[2] } return result
pattern_id = int(row['Pattern ID']) retrain_pattern = row['Insert to new DB then retrain'] should_retrain_pattern = retrain_pattern == 'y' if should_retrain_pattern: pattern_ids_to_retrain.append(pattern_id) progress = util.read_progress() n_patterns_to_retrain = len(pattern_ids_to_retrain) n_patterns_done = 0 for pattern_id in pattern_ids_to_retrain: print(pattern_id) # Load training match training_match_row = db.db_query( 'select * from pattern_training_matches_view where pattern_id = {}'. format(pattern_id), fetch='one', ) training_match_row = db.row_to_dict(training_match_row, 'pattern_training_matches_view') training_match_id = training_match_row['id'] training_match_sentence_id = training_match_row['sentence_id'] util.unpack_json_field(training_match_row, 'match_data') training_match_slots = training_match_row['slots'] training_match_document_id = training_match_row['document_id'] training_document_row = db.db_query( 'select * from documents where id = {}'.format( training_match_document_id), fetch='one',
new_db_path = config['new_db_file_path'] progress = util.read_progress() for pattern_id in progress['pattern_ids_inserted']: print( len(progress['pattern_ids_training_matches_mapped']), '/', len(progress['pattern_ids_inserted']), ) print('pattern_id', pattern_id) # Load training match from old DB training_match_row = db.db_query( 'select * from pattern_training_matches_view where pattern_id = {}'. format(pattern_id), fetch='one', ) training_match_row = db.row_to_dict(training_match_row, 'pattern_training_matches_view') training_match_id = training_match_row['id'] training_match_sentence_id = training_match_row['sentence_id'] training_match_data = json.loads(training_match_row['match_data']) slots = training_match_data['slots'] training_match = db.spacify_match(slots, training_match_sentence_id) # Load matches from new DB, find training match equivalents, and insert into pattern_training_matches match_rows = db.db_query( 'select * from pattern_matches_view where pattern_id = {}'.format( pattern_id), db_path=new_db_path,
with open('morphosource_recordsets_overt.csv', 'r') as csvfile: reader = csv.reader(csvfile) for line in reader: if line[2] == "Yes": overt_recordsets.append(line[0]) conn = db.db_conn() c = conn.cursor() sql = """ SELECT * FROM `ms_media_files` AS mf LEFT JOIN `ms_media` AS m on mf.media_id = m.media_id LEFT JOIN `ms_specimens` AS s on m.specimen_id = s.specimen_id LEFT JOIN `ms_institutions` AS i on s.institution_id = i.institution_id """ r = db.db_query(c, sql) m_array = [] inst_id_dict = {1: [], 11: [], 31: [], 50: []} insti_mfs = [] indiv_mfs = [] i = 0 for m in r: print i mf = ms_media_file.MsMediaFile(m) m_array.append(mf) # Institutional or individual? First, is it in the list of institution IDs? if mf.db_dict['i.institution_id'] in [1, 11, 31, 50]: insti_mfs.append(mf.db_dict['media_file_id'])
def main(args_dict): # Connect to the database db = psycopg2.connect(user='******', dbname='kataster') # Set up enum type division_level, table parties, table offices, table terms q = """ DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'division_level') THEN CREATE TYPE kataster.division_level AS ENUM ('country', 'region', 'district', 'municipality', 'borough'); END IF; END $$; """ q += """ DROP TABLE kataster.politicianterms; DROP TABLE kataster.politicians; DROP TABLE kataster.parties; DROP TABLE kataster.terms; DROP TABLE kataster.offices; """ q += """ CREATE TABLE IF NOT EXISTS kataster.offices( id int PRIMARY KEY, name_male text UNIQUE, name_female text UNIQUE, level kataster.division_level ); CREATE TABLE IF NOT EXISTS kataster.terms( id int PRIMARY KEY, officeid int REFERENCES kataster.offices(id), start int, finish int ); CREATE TABLE IF NOT EXISTS kataster.parties( id int PRIMARY KEY, abbreviation text, name text UNIQUE ); CREATE TABLE IF NOT EXISTS kataster.politicians( id serial PRIMARY KEY, firstname text, surname text, title text, dobhash int ); CREATE TABLE IF NOT EXISTS kataster.politicianterms( politicianid int REFERENCES kataster.politicians(id), termid int REFERENCES kataster.terms(id), party_nomid int REFERENCES kataster.parties(id), partyid int REFERENCES kataster.parties(id), source_url text, picture_url text, PRIMARY KEY (politicianid, termid) ); """ db_execute(db, q) # Insert offices path_offices = DIR_DATA + 'offices.json' offices = json_load(path_offices) columns_offices = ['id', 'name_male', 'name_female', 'level'] db_insert_jsons(db, 'kataster.offices', offices, columns_offices) # Insert terms path_terms = DIR_DATA + 'terms.json' terms = json_load(path_terms) columns_terms = ['id', 'officeid', 'start', 'finish'] db_insert_jsons(db, 'kataster.terms', terms, columns_terms) # Insert parties path_terms = DIR_DATA + 'parties.json' parties = json_load(path_terms) columns_parties = ['id', 'abbreviation', 'name'] db_insert_jsons(db, 'kataster.parties', parties, columns_parties) # Insert poslanci NRSR path_poslanci_NRSR = DIR_DATA + 'poslanci_NRSR.json' poslanci_NRSR = json_load(path_poslanci_NRSR) for poslanec in poslanci_NRSR: poslanec['dobhash'] = hash_timestamp(datetime.strptime(poslanec['birthdate'], '%Y-%m-%dT%H:%M:%SZ')) poslanci_NRSR_sorted = sorted(poslanci_NRSR, key=lambda p: (p['PoslanecID'], p['CisObdobia'])) poslanci_NRSR_unique = [next(group) for key, group in groupby(poslanci_NRSR_sorted, key=lambda p: p['PoslanecID'])] columns_politicians = ['firstname', 'surname', 'title', 'dobhash'] db_insert_jsons(db, 'kataster.politicians', poslanci_NRSR_unique, columns_politicians) # Obtain assigned IDs q = """SELECT id, firstname, surname, dobhash FROM kataster.politicians;""" politicians = db_query(db, q) fsd_to_politicianid = {(p['firstname'], p['surname'], p['dobhash']): p['id'] for p in politicians} # Construct politicianterms relations for poslanci NRSR CisObdobia_to_termid = {term['CisObdobia']: term['id'] for term in terms if 'CisObdobia' in term} party_name_to_id = {party['name']: party['id'] for party in parties} for poslanec in poslanci_NRSR: # Obtain politicianid key_fsd = (poslanec['firstname'], poslanec['surname'], poslanec['dobhash']) politicianid = fsd_to_politicianid[key_fsd] # Obtain termid termid = CisObdobia_to_termid[poslanec['CisObdobia']] # Obtain partynom party_nom = poslanec['party_nom'] party_nom_id = party_name_to_id[party_nom] if party_nom in party_name_to_id else '\N' # Insert the relation q = """ INSERT INTO kataster.politicianterms(politicianid, termid, party_nomid, partyid, source_url, picture_url) VALUES (%s, %s, %s, %s, %s, %s) ON CONFLICT DO NOTHING; """ q_data = (politicianid, termid, party_nom_id, None, poslanec['source'], poslanec['picture']) db_execute(db, q, q_data) # Commit changes and close connection to database db.commit() db.close()
def delete_all_pattern_matches(): query = 'delete from pattern_matches' db.db_query(query, fetch='none')
def consulta(): query = db_query("SELECT * FROM [dbo].[Cadastro];") return render_template('consulta.html', query=query)
logging.basicConfig(level = logging.INFO) logger = logging.getLogger(__name__) from db import db_query schedd = htcondor.Schedd() # First fetch the list of cluster ids that are still in the queue current_open_clusters = set() for jobads in schedd.xquery('True', ['ClusterId']): current_open_clusters.add(jobads['ClusterId']) # Prepare python -> mysql id mappings users = dict(db_query('SELECT `name`, `user_id` FROM `users`')) sites = {} for site_id, site_name, site_pool in db_query('SELECT `site_id`, `site_name`, `site_pool` FROM `sites`'): sites[(site_name, site_pool)] = site_id frontends = dict(db_query('SELECT `frontend_name`, `frontend_id` FROM `frontends`')) # Form the constraint expression for condor_history: # 1. All new clusters # 2. All clusters tagged open in the last iteration classad_attrs = ['GlobalJobId', 'ClusterId', 'ProcId', 'User', 'Cmd', 'MATCH_GLIDEIN_SiteWMS_Queue', 'LastRemoteHost', 'MATCH_GLIDEIN_SiteWMS_Slot', 'BOSCOCluster', 'MATCH_GLIDEIN_Site', 'LastRemotePool', 'LastMatchTime', 'RemoteWallClockTime', 'RemoteUserCpu', 'ExitCode', 'JobStatus'] open_clusters = db_query('SELECT `cluster_id` FROM `open_clusters`') open_clusters.extend(list(current_open_clusters)) open_clusters.sort()