Example #1
0
def get_listings():
    latitude = request.args.get('latitude')
    longitude = request.args.get('longitude')
    listing = Listings(latitude, longitude)
    payload = dict()
    payload['nearby'] = listing.get_listings()
    if payload['nearby']:
        payload['response'] = 'success'
    else:
        payload['response'] = 'invalid address'
    return payload
Example #2
0
    def __init__(self, config):
        gobject.GObject.__init__(self)
        self.config = config
        self.listings = Listings(config)

        self.path = self.config.xmltv_file

        self.__channel_names = {}
Example #3
0
class XMLTVFile(gobject.GObject):
    __gproperties__ = {"path": (str, "XMLTV file path", "The path to the XMLTV file", "", gobject.PARAM_READWRITE)}

    __gsignals__ = {
        "loading-done": (gobject.SIGNAL_RUN_LAST, None, (object,)),
        "loading": (gobject.SIGNAL_RUN_LAST, None, ()),
        "loaded-channel": (gobject.SIGNAL_RUN_LAST, None, (object,)),
        "downloading-logo": (gobject.SIGNAL_RUN_LAST, None, (object,)),
        "downloading-logo-done": (gobject.SIGNAL_RUN_LAST, None, (object,)),
        "downloading": (gobject.SIGNAL_RUN_LAST, None, ()),
        "downloading-done": (gobject.SIGNAL_RUN_LAST, None, (int, int)),
        "sorting": (gobject.SIGNAL_RUN_LAST, None, ()),
        "sorting-done": (gobject.SIGNAL_RUN_LAST, None, (int, int)),
    }

    def __init__(self, config):
        gobject.GObject.__init__(self)
        self.config = config
        self.listings = Listings(config)

        self.path = self.config.xmltv_file

        self.__channel_names = {}

    def do_get_property(self, property):
        if property.name == "path":
            return self.path

    def do_set_property(self, property, value):
        if property.name == "path":
            self.path = value

    def load(self, force_reload=False):
        thread.start_new_thread(self.__load_in_thread, (force_reload,))

    def __load_in_thread(self, force_reload):
        if os.path.exists(self.listings.file) and not force_reload:
            try:
                self.listings = self.listings.load()
            except:
                if self.config.debug:
                    os.rename(self.listings.file, "%s.debug" % self.listings.file)
        if self.has_changed() or force_reload:
            gtk.gdk.threads_enter()
            self.emit("loading")
            gtk.gdk.threads_leave()

            title = error_msg = ""
            try:
                self.__load_channels()
                self.__load_programs()
                self.listings.mtime = os.path.getmtime(self.path)
                if self.config.debug:
                    print("Loaded listings from XMLTV file: %s" % self.path)
            except IOError, ioe:
                title = _("Failed to load %s") % self.path
                if ioe.errno == 2:
                    error_msg = _("File not found")
                elif ioe.errno == 13:
                    error_msg = _("Access denied")
                else:
                    error_msg = _("Unknown error")
            except SyntaxError, se:
                title = _("Error while parsing %s") % self.path
                error_msg = _('The parser returned: "%s"') % se
                # error_msg = _("Not well formed at line %s, column %s") % \
                # (se.lineno, se.offset)
            except Exception, e:
                title = _("Unknown error while loading %s") % self.path
                error_msg = str(e)