Ejemplo n.º 1
0
def get_channel_key_from_id(chan_id, plus1=False):
    #
    try:
        package = get_cfg_details_package()
        #
        # Do HD first as preference
        # If HD does not yield results, fall back to SD
        # then, check plus 1 channels, repeating hd preference over sd
        #
        if plus1:
            if 'plus1' in channels[chan_id]:
                #
                if 'hd' in channels[chan_id]['plus1']:
                    if check_package_plus1(chan_id, 'hd', package):
                        return channels[chan_id]['plus1']['hd']['key']
                #
                if 'sd' in channels[chan_id]['plus1']:
                    if check_package_plus1(chan_id, 'sd', package):
                        return channels[chan_id]['plus1']['sd']['key']
            #
        else:
            if 'hd' in channels[chan_id]:
                if check_package(chan_id, 'hd', package):
                    return channels[chan_id]['hd']['key']
            #
            if 'sd' in channels[chan_id]:
                if check_package(chan_id, 'sd', package):
                    return channels[chan_id]['sd']['key']
        #
        return False
    except Exception as e:
        log_internal(logException, logDesChannel_KeyFromId.format(id=chan_id, plus1=plus1), description='fail', exception=e)
        return False
def send_notifications_all(child_id, objObs):
    #
    count = 0
    #
    for objOb in objObs:
        try:
            result = email_observations(objOb)
        except smtplib.SMTPDataError as e:
            log_internal(logException, 'scheduled operation',
                         description='Error sending email for {id}'.format(id=objOb.id()),
                         exception=e)
            raise Exception
        except Exception as e:
            log_internal(logException, 'scheduled operation',
                         description='Error sending email for {id}'.format(id=objOb.id()),
                         exception=e)
            result = False
        if result:
            add_history(child_id, objOb.id(),
                        objOb.title(),
                        objOb.comment(), objOb.commentby(),
                        objOb.aol_html(),
                        len(objOb.imgs()),
                        len(objOb.vids()),
                        objOb.date_observation(),
                        datetime.now().strftime('%Y/%m/%d %H:%M'))
            count += 1
    #
    return count
Ejemplo n.º 3
0
def get_channels(package):
    #
    chans = {}
    #
    for chan_id in channels:
        #
        try:
            #
            chans[chan_id] = {}
            chans[chan_id]['quality'] = []
            chans[chan_id]['name'] = channels[chan_id]['name']
            #
            if check_package(chan_id, 'sd', package):
                chans[chan_id]['quality'].append('sd')
            if check_package(chan_id, 'hd', package):
                chans[chan_id]['quality'].append('hd')
            #
            if 'plus1' in channels[chan_id]:
                chans[chan_id]['plus1'] = {}
                chans[chan_id]['plus1']['quality'] = []
                chans[chan_id]['plus1']['name'] = channels[chan_id]['plus1']['name']
                #
                if check_package_plus1(chan_id, 'sd', package):
                    chans[chan_id]['plus1']['quality'].append('sd')
                if check_package_plus1(chan_id, 'hd', package):
                    chans[chan_id]['plus1']['quality'].append('hd')
            #
        except Exception as e:
            log_internal(logException, logDesChannel_ListFromPackage.format(package=package), description='fail', exception=e)
    #
    return {'channels': chans}
Ejemplo n.º 4
0
 def _tokencheck(self):
     log_internal(logPass, logDescNest_checkingAuth)
     if self._checkToken():
         return True
     else:
         # TODO - capability to get new token when old one expires
         return False
Ejemplo n.º 5
0
def get_channel_item(chan_id):
    try:
        return channels[chan_id]
    except Exception as e:
        log_internal(logException,
                     logDesc_channel_functions_getItem,
                     description='channel "{chan_id}"'.format(chan_id=chan_id),
                     exception=e)
        return False
Ejemplo n.º 6
0
def get_channel_item_plus1(chan_id):
    try:
        item = get_channel_item(chan_id)
        return item['hasPlus1']
    except Exception as e:
        log_internal(logException,
                     logDesc_channel_functions_getSource_offset,
                     description='channel "{chan_id}"'.format(chan_id=chan_id),
                     exception=e)
        return False
Ejemplo n.º 7
0
def get_channel_item_listingsrc_id(chan_id, src):
    try:
        chan = get_channel_item_listingsrc(chan_id, src)
        return chan['id']
    except Exception as e:
        log_internal(logException,
                     logDesc_channel_functions_getSource_id,
                     description='channel "{chan_id}" and source "{src}"'.format(chan_id=chan_id, src=src),
                     exception=e)
        return False
Ejemplo n.º 8
0
def get_channel_item_listingsrc_list(chan_id):
    try:
        chan = get_channel_item(chan_id)
        return chan['dataSources'].keys()
    except Exception as e:
        log_internal(logException,
                     logDesc_channel_functions_getSources,
                     description='channel "{chan_id}"'.format(chan_id=chan_id),
                     exception=e)
        return False
Ejemplo n.º 9
0
def start_bottle():

    ################################################################################################
    # Create device
    ################################################################################################

    _weather = Weather()
    _sunrisesunset = SunsetSunrise()

    log_internal(logPass, logDescDeviceObjectCreation, description='success')

    ################################################################################################
    # APIs
    ################################################################################################

    @route('/config', method=['OPTIONS'])
    @route('/weather/all', method=['OPTIONS'])
    @route('/weather/location', method=['OPTIONS'])
    @route('/weather/forecast/<option>', method=['OPTIONS'])
    @route('/weather/sunrise-sunset/<date>', method=['OPTIONS'])
    def api_cors_options(**kwargs):
        return response_options()

    @get('/config')
    def api_get_config():
        response = get_config(request)
        return enable_cors(response)

    @get('/weather/all')
    def api_get_all():
        response = get_all(request, _weather, _sunrisesunset)
        return enable_cors(response)

    @get('/weather/location')
    def api_get_location():
        response = get_location(request, _weather)
        return enable_cors(response)

    @get('/weather/forecast/<option>')
    def api_get_forecast(option):
        response = get_forecast(request, _weather, option)
        return enable_cors(response)

    @get('/weather/sunrise-sunset/<date>')
    def api_get_sunrisesunset(date):
        response = get_sunrisesunset(request, _weather, _sunrisesunset, date)
        return enable_cors(response)

    ################################################################################################

    host = '0.0.0.0'
    port = get_cfg_port()
    run(host=host, port=port, server='paste', debug=True)

    log_internal(logPass, logDescPortListener.format(port=port), description='started')
 def sendCmd(self, command):
     try:
         r_pass = self._send_telnet(get_cfg_details_ip(),
                                    self._port,
                                    data=commands[command])
         #
         result = logPass if r_pass else logFail
         log_internal(result, logDescDeviceSendCommand)
         return r_pass
     except Exception as e:
         log_internal(logException, logDescDeviceSendCommand, exception=e)
         return False
Ejemplo n.º 11
0
def get_channel_item_listingsrc(chan_id, src):
    try:
        item = get_channel_item(chan_id)
        if bool(item):
            return item['dataSources'][src]
        return False
    except Exception as e:
        log_internal(logException,
                     logDesc_channel_functions_getSource_details,
                     description='channel "{chan_id}" and source "{src}"'.format(chan_id=chan_id, src=src),
                     exception=e)
        return False
 def getChannels(self):
     try:
         r_pass = get_channels(get_cfg_details_package())
         #
         result = logPass if r_pass else logFail
         log_internal(result, logDescDeviceGetChannelsForPackage)
         return r_pass
     except Exception as e:
         log_internal(logException,
                      logDescDeviceGetChannelsForPackage,
                      exception=e)
         return False
 def getRecordings(self):
     try:
         self._check_recordings()
         #
         return {
             'recordings': self.recordings,
             'timestamp':
             self.recordings_timestamp.strftime('%d/%m/%Y %H:%M')
         }
     except Exception as e:
         log_internal(logException, logDescDeviceGetRecordings, exception=e)
         return {'recordings': False, 'timestamp': 'n/a'}
 def getCommands(self):
     #
     try:
         cmds = []
         #
         for c in commands:
             cmds.append(c)
         #
         return {'commands': cmds}
     except Exception as e:
         log_internal(logException, logDescDeviceGetCommand, exception=e)
         return {'commands': []}
Ejemplo n.º 15
0
def broadcast_service(service_id, self_port):
    try:
        #
        msg = jarvis_broadcast_msg.format(service_id=service_id,
                                          service_type=serviceType,
                                          port=str(self_port))
        #
        while True:
            broadcast_msg(msg)
            sleep(broadcast_frequency)
        #
    except Exception as e:
        log_internal(logException, logDesc_services_Broadcast, exception=e)
Ejemplo n.º 16
0
def broadcast_msg(msg):
    try:
        s = socket(AF_INET, SOCK_DGRAM)
        s.bind(('0.0.0.0', 0))
        s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
        #
        s.sendto(msg.encode(), ('<broadcast>', jarvis_broadcastPort))
        #
        return True
        #
    except Exception as e:
        #
        log_internal(logException, logDesc_Broadcast, exception=e)
        return False
Ejemplo n.º 17
0
def start_bottle():

    ################################################################################################
    # APIs
    ################################################################################################

    @get('/config')
    def api_get_config():
        return get_config(request)

    @get('/')
    def api_get_ui_index():
        return get_ui_index(request)

    @get('/config/config.js')
    def api_get_ui_config():
        return get_ui_config(request)

    @get('/static/<type>/<filename>')
    def api_get_ui_resource(type, filename):
        return get_ui_resource(request, type, filename)

    @get('/favicon.ico')
    def api_get_ui_favicon():
        return get_ui_favicon(request)

    @get('/images/<type>/<filename>')
    def api_get_ui_image(type, filename):
        return get_ui_image(request, type, filename)

    @get('/modules/<module>/<filename>')
    def api_get_ui_module(module, filename):
        return get_ui_module(request, module, filename)

    @post('/modules')
    def api_post_ui_config():
        return post_ui_modules(request)

    ################################################################################################

    host = '0.0.0.0'
    port = get_cfg_port()
    run(host=host, port=port, server='paste', debug=True)

    log_internal(logPass,
                 logDescPortListener.format(port=port),
                 description='started')
Ejemplo n.º 18
0
 def build_listing_dict(self):
     #
     for chan_id in channels:
         #
         self._listings[chan_id] = {}
         #
         # real-time/non-plus1
         try:
             self._listings[chan_id]['listings'] = self._getlisting(chan_id, 0)
         except Exception as e:
             log_internal(logException,
                          logDesc_retrieve_listing.format(channel=chan_id),
                          description='-',
                          exception=e)
         #
         # plus1
         self._listings[chan_id]['hasPlus1'] = get_channel_item_plus1(chan_id)
Ejemplo n.º 19
0
def start_bottle():

    ################################################################################################
    # Create device
    ################################################################################################

    _tvlistings = TVlistings()

    log_internal(logPass, logDescDeviceObjectCreation, description='success')

    ################################################################################################
    # APIs
    ################################################################################################

    @route('/config', method=['OPTIONS'])
    @route('/tvlistings/all', method=['OPTIONS'])
    @route('/tvlistings/channel/<channame>', method=['OPTIONS'])
    def api_cors_options(**kwargs):
        return response_options()

    @get('/config')
    def api_get_config():
        response = get_config(request)
        return response

    @get('/tvlistings/all')
    def api_get_tvlistings_all():
        response = get_tvlistings_all(request, _tvlistings)
        return response

    @get('/tvlistings/channel/<channame>')
    def api_get_tvlistings_channel(channame):
        response = get_tvlistings_channel(request, _tvlistings, channame)
        return response

    ################################################################################################

    host = '0.0.0.0'
    port = get_cfg_port()
    run(host=host, port=port, server='paste', debug=True)

    log_internal(logPass,
                 logDescPortListener.format(port=port),
                 description='started')
 def sendPin(self):
     #
     pin = get_cfg_details_pin()
     #
     try:
         rsp = []
         for num in pin:
             code = commands[num]
             rsp.append(
                 self._send_telnet(get_cfg_details_ip(),
                                   self._port,
                                   data=code))
         #
         result = logPass if not (False in rsp) else logFail
         log_internal(result, logDescDeviceSendPin)
         return not (False in rsp)
     except Exception as e:
         log_internal(logException, logDescDeviceSendPin, exception=e)
         return False
Ejemplo n.º 21
0
def start_bottle():

    ################################################################################################
    # Create device
    ################################################################################################

    _xbox = Xboxone()

    log_internal(logPass, logDescDeviceObjectCreation, description='success')

    ################################################################################################
    # APIs
    ################################################################################################

    @route('/config', method=['OPTIONS'])
    @route('/powerstatus', method=['OPTIONS'])
    @route('/command', method=['OPTIONS'])
    def api_cors_options(**kwargs):
        return response_options()

    @get('/config')
    def api_get_config():
        response = get_config(request)
        return response

    @get('/powerstatus')
    def api_get_powerstatus():
        response = get_powerstatus(request, _xbox)
        return response

    @post('/command')
    def api_post_command():
        response = post_command(request, _xbox)
        return response

    ################################################################################################

    host = '0.0.0.0'
    port = get_cfg_port()
    run(host=host, port=port, server='paste', debug=True)

    log_internal(logPass, logDescPortListener.format(port=port), description='started')
Ejemplo n.º 22
0
 def _getlisting(self, chan_id, offset):
     #
     listing_srcs = get_channel_item_listingsrc_list(chan_id)
     #
     if not listing_srcs:
         log_internal(logFail,
                      logDesc_retrieve_listing_no_source.format(channel=chan_id),
                      description='-')
         return {}
     #
     if len(listing_srcs)>0:
         for src in listing_srcs:
             try:
                 #
                 id = get_channel_item_listingsrc_id(chan_id, src)
                 #
                 if src == 'bleb':
                     log_internal(logPass,
                                  logDesc_retrieve_listing.format(channel=chan_id),
                                  description=src)
                     return data_source_bleb.get(id, offset)
             except Exception as e:
                 log_internal(logException,
                              logDesc_retrieve_listing.format(channel=chan_id),
                              description=src,
                              exception=e)
     return {}
Ejemplo n.º 23
0
def get_channel_details_from_key(key):
    #
    try:
        for chan_id in channels:
            #
            if 'sd' in channels[chan_id]:
                if channels[chan_id]['sd']['key'] == key:
                    return {'id': chan_id,
                            'name': channels[chan_id]['name'],
                            'quality': 'sd',
                            'plus1': False}
            #
            if 'hd' in channels[chan_id]:
                if channels[chan_id]['hd']['key'] == key:
                    return {'id': chan_id,
                            'name': channels[chan_id]['name'],
                            'quality': 'hd',
                            'plus1': False}
            #
            if 'plus1' in channels[chan_id]:
                #
                if 'sd' in channels[chan_id]['plus1']:
                    if channels[chan_id]['plus1']['sd']['key'] == key:
                        return {'id': chan_id,
                                'name': channels[chan_id]['plus1']['sd']['name'],
                                'quality': 'sd',
                                'plus1': True}
                #
                if 'hd' in channels[chan_id]['plus1']:
                    if channels[chan_id]['plus1']['hd']['key'] == key:
                        return {'id': chan_id,
                                'name': channels[chan_id]['plus1']['sd']['name'],
                                'quality': 'hd',
                                'plus1': True}
        #
        return False
    except Exception as e:
        log_internal(logException, logDesChannel_DetailsFromKey.format(key=key), description='fail', exception=e)
        return False
Ejemplo n.º 24
0
def get_channel_id_from_key(key):
    #
    try:
        k = int(key)
        #
        for chan_id in channels:
            if 'sd' in channels[chan_id]:
                if channels[chan_id]['sd']['key'] == k:
                    return chan_id
            if 'hd' in channels[chan_id]:
                if channels[chan_id]['hd']['key'] == k:
                    return chan_id
            if 'plus1' in channels[chan_id]:
                if 'sd' in channels[chan_id]['plus1']:
                    if channels[chan_id]['sd']['plus1']['key'] == k:
                        return chan_id
                if 'hd' in channels[chan_id]:
                    if channels[chan_id]['hd']['plus1']['key'] == k:
                        return chan_id
        #
        return False
    except Exception as e:
        log_internal(logException, logDesChannel_NameFromKey.format(key=key), description='fail', exception=e)
        return False
 def sendChannel(self, chan_id, plus1=False):
     try:
         chan_key = get_channel_key_from_id(chan_id, plus1)
         if chan_key:
             response = self._send_telnet(
                 ipaddress=get_cfg_details_ip(),
                 port=self._port,
                 data=("SETCH {chan_key}\r").format(chan_key=chan_key),
                 response=True)
             if not isinstance(response, bool):
                 if response.startswith('CH_FAILED'):
                     log_internal(logFail, logDescDeviceSendChannel)
                     return False
                 else:
                     log_internal(logPass, logDescDeviceSendChannel)
                     return True
         log_internal(logFail, logDescDeviceSendChannel)
         return False
     except Exception as e:
         log_internal(logException, logDescDeviceSendChannel, exception=e)
         return False
    def _create_recordings_json(self, _timestamp, _folders, _files):
        #
        json_recordings = {}

        #
        if len(_folders) == 0 or len(_files) == 0:
            return False
        #
        try:
            #
            folderCount = 0
            for itemFolder in _folders:
                if itemFolder.find(
                        'Title').text != 'Suggestions' and itemFolder.find(
                            'Title').text != 'HD Recordings':
                    json_recordings[str(folderCount)] = {}
                    json_recordings[str(folderCount)][
                        'folderName'] = itemFolder.find('Title').text
                    json_recordings[str(folderCount)]['type'] = '-'
                    #
                    json_recordings[str(folderCount)]['items'] = {}
                    #
                    # Run through individual items
                    itemCount = 0
                    for itemFile in _files:
                        #
                        if itemFile.find('Title').text == itemFolder.find(
                                'Title').text:
                            #
                            json_recordings[str(folderCount)]['items'][str(
                                itemCount)] = {}
                            #
                            try:
                                json_recordings[str(folderCount)]['items'][
                                    str(itemCount
                                        )]['episodeTitle'] = itemFile.find(
                                            'EpisodeTitle').text
                            except Exception as e:
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['episodeTitle'] = ''
                            #
                            json_recordings[str(folderCount)]['items'][str(
                                itemCount)]['channel'] = {}
                            #
                            recordedChannel = int(
                                itemFile.find('SourceChannel').text)
                            c = get_channel_details_from_key(recordedChannel)
                            if c:
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['channel']['id'] = c['id']
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['channel']['name'] = c['name']
                                json_recordings[str(folderCount)]['items'][
                                    str(itemCount
                                        )]['channel']['quality'] = c['quality']
                                json_recordings[str(folderCount)]['items'][
                                    str(itemCount
                                        )]['channel']['plus1'] = c['plus1']
                            else:
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['channel']['id'] = '-'
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['channel']['name'] = '-'
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['channel']['quality'] = '-'
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['channel']['plus1'] = '-'
                            #
                            try:
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['description'] = itemFile.find(
                                        'Description').text
                            except Exception as e:
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['description'] = ''
                            #
                            try:
                                date = int(
                                    itemFile.find('CaptureDate').text, 0)
                                date = datetime.fromtimestamp(date)
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount
                                )]['recordingDate'] = date.strftime('%d-%m-%Y')
                            except Exception as e:
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['recordingDate'] = '-'
                            #
                            json_recordings[str(folderCount)]['items'][str(
                                itemCount)]['episodeNumber'] = {}
                            #
                            try:
                                episodenumber = itemFile.find(
                                    'EpisodeNumber').text
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['episodeNumber'][
                                        'series'] = episodenumber[:-2]
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['episodeNumber'][
                                        'episode'] = episodenumber[-2:]
                            except:
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['episodeNumber']['series'] = ''
                                json_recordings[str(folderCount)]['items'][
                                    str(itemCount
                                        )]['episodeNumber']['episode'] = ''
                            #
                            try:
                                if itemFile.find('ProgramId').text.startswith(
                                        'EP'):
                                    json_recordings[str(
                                        folderCount)]['type'] = 'tv'
                                    json_recordings[str(folderCount)]['items'][
                                        str(itemCount)]['mpaaRating'] = ''
                                elif itemFile.find(
                                        'ProgramId').text.startswith('MV'):
                                    json_recordings[str(
                                        folderCount)]['type'] = 'movie'
                                    json_recordings[str(folderCount)]['items'][
                                        str(itemCount
                                            )]['mpaaRating'] = itemFile.find(
                                                'MpaaRating').text
                            except:
                                json_recordings[str(folderCount)]['items'][str(
                                    itemCount)]['mpaaRating'] = ''
                                #
                            itemCount += 1
                #
                folderCount += 1
            #
            return json_recordings
            #
        except Exception as e:
            log_internal(logException,
                         logDescDeviceCreateRecordingsHtml,
                         exception=e)
            return False
Ejemplo n.º 27
0
def start_bottle():

    ################################################################################################
    # Create device
    ################################################################################################

    _nest = Nest()

    log_internal(logPass, logDescDeviceObjectCreation, description='success')

    ################################################################################################
    # APIs
    ################################################################################################

    @route('/config', method=['OPTIONS'])
    @route('/all', method=['OPTIONS'])
    @route('/structures', method=['OPTIONS'])
    @route('/structure/<structure_id>', method=['OPTIONS'])
    @route('/devices', method=['OPTIONS'])
    @route('/devices/<device_type>', method=['OPTIONS'])
    @route('/devices/<device_type>/<device_id>', method=['OPTIONS'])
    def api_cors_options(**kwargs):
        return response_options()

    @get('/config')
    def api_get_config():
        response = get_config(request)
        return enable_cors(response)

    @get('/all')
    def api_get_all():
        response = get_all(request, _nest)
        return enable_cors(response)

    @get('/structures')
    def api_get_structures():
        response = get_structures(request, _nest)
        return enable_cors(response)

    @get('/structure/<structure_id>')
    def api_get_structure_specific(structure_id):
        response = get_structure_specific(request, _nest, structure_id)
        return enable_cors(response)

    @get('/devices')
    def api_get_devices():
        response = get_devices(request, _nest)
        return enable_cors(response)

    @get('/devices/<device_type>')
    def api_get_devices_type(device_type):
        response = get_devices_type(request, _nest, device_type)
        return enable_cors(response)

    @get('/devices/<device_type>/<device_id>')
    def api_get_device_specific(device_type, device_id):
        response = get_device_specific(request, _nest, device_type, device_id)
        return enable_cors(response)

    @post('/devices/<device_type>/<device_id>')
    def api_post_device_specific(device_type, device_id):
        response = post_device_specific(request, _nest, device_type, device_id)
        return enable_cors(response)

    ################################################################################################

    host = '0.0.0.0'
    port = get_cfg_port()
    run(host=host, port=port, server='paste', debug=True)

    log_internal(logPass,
                 logDescPortListener.format(port=port),
                 description='started')
 def get_recordings(self):
     # Reset value
     self.recordings = False
     #
     try:
         #
         ############
         #
         folders = self._retrieve_recordings('No')
         folders = folders.replace(
             ' xmlns="http://www.tivo.com/developer/calypso-protocol-1.6/"',
             '')
         folders = ET.fromstring(folders)
         xml_folders = []
         for item in folders.iter('Item'):
             xml_folders.append(item.find('Details'))
         #
         ############
         #
         retrieve_items = 50
         #
         files_repeat = True
         loop_count = 0
         itemCount = '&ItemCount={retrieve_items}'.format(
             retrieve_items=retrieve_items)
         xml_files = []
         #
         while files_repeat:
             files_count = 0
             files = self._retrieve_recordings(
                 'Yes', itemCount=itemCount
             ).replace(
                 ' xmlns="http://www.tivo.com/developer/calypso-protocol-1.6/"',
                 '')
             files = ET.fromstring(files)
             # Run through individual items
             for item in files.iter('Item'):
                 xml_files.append(item.find('Details'))
                 files_count += 1
             #
             if files_count < 50:
                 files_repeat = False
             else:
                 loop_count += 1
                 itemCount = '&ItemCount={retrieve_items}&AnchorOffset={AnchorOffset}'.format(
                     retrieve_items=retrieve_items,
                     AnchorOffset=(retrieve_items * loop_count))
         #
         ############
         #
         self.recordings_timestamp = datetime.now()
         self.recordings = self._create_recordings_json(
             self.recordings_timestamp, xml_folders, xml_files)
         #
         ############
         #
         log_internal(logPass, logDescDeviceGetRecordings)
         #
     except Exception as e:
         log_internal(logException, logDescDeviceGetRecordings, exception=e)
         self.recordings_timestamp = 0
         self.recordings = False
                                datetime.time(s).hour, 0, 0,
                                0) + datetime.timedelta(days=1)
    elif now.hour < datetime.time(s).hour:
        nxt = datetime.datetime(now.year, now.month, now.day,
                                datetime.time(s).hour, 0, 0, 0)
    else:
        nxt = now + datetime.timedelta(hours=1)
    #
    return nxt


while True:
    #
    now = datetime.datetime.now()
    #
    log_internal(logPass, 'Operation started')
    #
    try:
        s = create_session(config.get_config_primaryessence_nursery(),
                           config.get_config_primaryessence_prefix(),
                           config.get_config_primaryessence_username(),
                           config.get_config_primaryessence_password())
        #
        count = 0
        #
        r = {}
        o = {}
        for child_id in config.get_config_primaryessence_childids():
            r[child_id] = get_learningJournal(s, child_id)
            o[child_id] = find_observations(s, r[child_id], child_id)
            #
Ejemplo n.º 30
0
import sys
from multiprocessing import Process
from resources.global_resources.log_vars import logPass, logException
from resources.lang.enGB.logs import *
from config.config import get_cfg_serviceid, get_cfg_port
from discovery.broadcast import broadcast_service
from log.log import log_internal
from portlistener import start_bottle

try:

    ################################

    log_internal(logPass, logDescStartingService, description='started')

    ################################
    # Initiate service broadcast

    process_broadcast = Process(target=broadcast_service,
                                args=(
                                    get_cfg_serviceid(),
                                    get_cfg_port(),
                                ))
    process_broadcast.start()

    ################################
    # Port_listener

    log_internal(logPass,
                 logDescPortListener.format(port=get_cfg_port()),
                 description='starting')