def channel_check(): def SQL_TASK(channel): name = channel[0] pid = channel[3] pid = pid(name) if pid == 'none': pid = 0 state = channel[5] state = state(name) svr = host_name SQL_QUERY = "SELECT * " \ "FROM channels;" SQL_INSERT = "INSERT INTO channels (pid,name,state,svr) " \ "VALUES ({},'{}','{}','{}');".format(pid, name, state, svr) SQL_UPDATE = "UPDATE channels " \ "SET pid={},state='{}',svr='{}' " \ "WHERE name='{}' AND svr='{}';".format(pid, state, svr, name, svr) cur.execute(SQL_QUERY) res = cur.fetchall() my_list = [] for item in res: my_list.append(item[2]) if name in my_list and state == 'enabled': cur.execute(SQL_UPDATE) conn.commit() elif name not in my_list and state == 'enabled': cur.execute(SQL_INSERT) conn.commit() CMS_DICT = content() radio = CMS_DICT['radio'] tv = CMS_DICT['tv'] connect_str = "dbname='recording' user='******' host='mail.novusgroup.co.za' password='******'" conn = psycopg2.connect(connect_str) cur = conn.cursor() host_name = socket.gethostname() if host_name == 'radio': for channel in radio: SQL_TASK(channel) elif host_name == 'radio-backup': for channel in radio: SQL_TASK(channel) elif host_name == 'novflask': for channel in tv: SQL_TASK(channel) cur.close() conn.close()
from app import content CMS_DICT = content() def rmain(): pass def tmain(): pass def get_pid(): pass def get_auto(): pass def set_auto(): pass for item in CMS_DICT['radio']: with open('timestamps/' + item[0] + '.ts', 'w') as f: if f: print('file exists') else:
from app import content CMS = content() tv = CMS['tv'] status = 2 for c in tv: c = c[0] with open('/Novus_recording_system/auto/{}.auto'.format(c), 'r') as f: if f.read() == 'disabled': status = 0 else: status = 1 if __name__ == '__main__': print(status)