class File(common.Module): """ File module """ def __init__(self, server): """ Constructor @param[in] server - the parent object (the mediaserver that keeps the network module) """ common.Module.__init__(self, UUID, NAME, server) def addFile(self, name, path, type_name): """ Adds a new file @param[in] name - the internal name for operation inside KLK @param[in] path - the file path @param[in] type_name - the file type name """ try: db = self.getDB() conn = db.connect() cursor = conn.cursor() uuid = None return_value = 0 args = ( uuid, name, path, self._server.uuid, type_name, return_value, ) cursor.callproc('klk_file_add_cli', args) cursor.execute('SELECT @_klk_file_add_cli_5') rows = cursor.fetchone() if rows[0] != 0: print rows[0] raise common.KLKException,\ "MySQL error: cannot add a file" conn.commit() cursor.close() except MySQLdb.Error, e: raise common.KLKException,\ "MySQL error %d: %s" % (e.args[0], e.args[1]) # notify the module about the changes adapter = self._server.modules[klk.adapter.NAME] adapter.sendSyncMessage(UUID, DBUPDATE_MESSAGE)
class HTTPSource(common.Module): """ HTTP Source module """ def __init__(self, server): """ Constructor @param[in] server - the parent object (the mediaserver that keeps the network module) """ common.Module.__init__(self, UUID, NAME, server) def addSource(self, name, address, login, passwd): """ Adds a new http source @param[in] name - the item's name @param[in] address - the http address where the source can be got @param[in] login - the HTTP login. Empty value means no auth. @param[in] passwd - the HTTP passwd """ try: db = self.getDB() conn = db.connect() cursor = conn.cursor() uuid = None return_value = 0 description = '%s: %s' % (name, address) args = (uuid, name, address, login, \ passwd, description, return_value) cursor.callproc('klk_httpsrc_add', args) cursor.execute('SELECT @_klk_httpsrc_add_6') rows = cursor.fetchone() if rows[0] != 0: print rows[0] raise common.KLKException,\ "MySQL error: cannot add an http source" conn.commit() cursor.close() except MySQLdb.Error, e: raise common.KLKException,\ "MySQL error %d: %s" % (e.args[0], e.args[1]) # notify the module about the changes adapter = self._server.modules[klk.adapter.NAME] adapter.sendSyncMessage(UUID, DBUPDATE_MESSAGE)
cursor.execute('SELECT @_klk_app_http_streamer_route_del_byname_1') rows = cursor.fetchone() if rows[0] != 0: print rows[0] raise common.KLKException,\ "MySQL error: cannot delete a http streamer input route" conn.commit() cursor.close() except MySQLdb.Error, e: raise common.KLKException,\ "MySQL error %d: %s" % (e.args[0], e.args[1]) # notify the module about the changes adapter = self._server.modules[klk.adapter.NAME] adapter.sendSyncMessage(UUID, DBUPDATE_MESSAGE) def addInputRoute(self, net_route, path, media_type): """ Adds an input route """ app_uuid = self.app_uuid try: db = self.getDB() conn = db.connect() cursor = conn.cursor() # INOUT uuid VARCHAR(40), # IN application VARCHAR(40), # IN in_route VARCHAR(40), # IN out_path VARCHAR(40),