示例#1
0
def get_loggingpath(loggingpath=None):
    if loggingpath is None:
        if LOGGING_FILE_NAME is not None:
            # the config file must be found at DEFAULT_PATH
            loggingpath = os.path.expanduser(DEFAULT_PATH)
            fileUtils.check_dir(loggingpath)
            loggingpath = os.path.join(loggingpath, LOGGING_FILE_NAME)
        return loggingpath
    else:
        return loggingpath
示例#2
0
 def coord_to_path_checkdirs(self, tile_coord, layer):
     self.lock.acquire()
     path = os.path.join(self.configpath, MAP_SERVICES[layer]["layerDir"],)
     path = fileUtils.check_dir(path)
     path = fileUtils.check_dir(path, '%d' % tile_coord[2])
     path = fileUtils.check_dir(path, "%d" % (tile_coord[0] / 1024))
     path = fileUtils.check_dir(path, "%d" % (tile_coord[0] % 1024))
     path = fileUtils.check_dir(path, "%d" % (tile_coord[1] / 1024))
     self.lock.release()
     return os.path.join(path, "%d.png" % (tile_coord[1] % 1024))
def get_loggingpath(loggingpath=None):
    if loggingpath is None:
        if LOGGING_FILE_NAME is not None:
            # the config file must be found at DEFAULT_PATH
            loggingpath = os.path.expanduser(DEFAULT_PATH)
            fileUtils.check_dir(loggingpath)
            loggingpath = os.path.join(loggingpath, LOGGING_FILE_NAME)
        return loggingpath
    else:
        return loggingpath
示例#4
0
 def coord_to_path_checkdirs(self, tile_coord, layer):
     self.lock.acquire()
     path = fileUtils.check_dir(self.configpath)
     path = fileUtils.check_dir(
         path,
         "Yahoo" + MAP_SERVICES[layer]["layerName"][:3] + \
         "_" + str(MAP_MAX_ZOOM_LEVEL - tile_coord[2])
     )
     path = fileUtils.check_dir(
         path, self.calc_v2_hash(tile_coord[0], tile_coord[1]))
     self.lock.release()
     return os.path.join(path, "%d_%d.mgm" % (tile_coord[0], tile_coord[1]))
示例#5
0
 def coord_to_path_checkdirs(self, tile_coord, layer):
     self.lock.acquire()
     path = os.path.join(
         self.configpath,
         MAP_SERVICES[layer]["layerDir"],
     )
     path = fileUtils.check_dir(path)
     path = fileUtils.check_dir(path, '%d' % tile_coord[2])
     path = fileUtils.check_dir(path, "%d" % (tile_coord[0] / 1024))
     path = fileUtils.check_dir(path, "%d" % (tile_coord[0] % 1024))
     path = fileUtils.check_dir(path, "%d" % (tile_coord[1] / 1024))
     self.lock.release()
     return os.path.join(path, "%d.png" % (tile_coord[1] % 1024))
示例#6
0
 def coord_to_path_checkdirs(self, tile_coord, layer):
     self.lock.acquire()
     path = fileUtils.check_dir(self.configpath)
     path = fileUtils.check_dir(
         path,
         "Yahoo" + MAP_SERVICES[layer]["layerName"][:3] + \
         "_" + str(MAP_MAX_ZOOM_LEVEL - tile_coord[2])
     )
     path = fileUtils.check_dir(
         path, self.calc_v2_hash(tile_coord[0], tile_coord[1])
     )
     self.lock.release()
     return os.path.join(path, "%d_%d.mgm" % (tile_coord[0], tile_coord[1]))
示例#7
0
 def run(self, w, init_path, repostype, strFolder):
     # Creating our own gmap
     self.gmap = mapServices.MapServ(init_path, repostype)
     self.complete = []
     self.downloader = MapDownloader(self.gmap)
     if self.conf.map_service in NO_BULK_DOWN:
         if not legal_warning(self, self.conf.map_service, "bulk downloading"):
             self.all_done("Canceled")
             return
     args = MapArgs()
     if self.processing:
         return
     try:
         args.lat = float(self.e_lat0.get_text())
         args.lng = float(self.e_lon0.get_text())
         args.width = float(self.e_kmx.get_text())
         args.height = float(self.e_kmy.get_text())
         args.min_zl = self.s_zoom0.get_value_as_int()
         args.max_zl = self.s_zoom1.get_value_as_int()
         layer = self.layer
     except ValueError:
         d = gtk.MessageDialog(
             self, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "Some field contain non-numbers"
         )
         d.run()
         d.destroy()
         return
     self.b_pause.set_sensitive(True)
     self.b_download.set_sensitive(False)
     self.b_open.set_sensitive(False)
     # Save the map info
     self.save_info(check_dir(strFolder), str(args))
     self.pbar.set_text(" ")
     self.processing = True
     self.downloader.bulk_download(
         (args.lat, args.lng, 15),
         (args.min_zl, args.max_zl),
         args.width,
         args.height,
         layer,
         gui_callback(self.tile_received),
         self.download_complete,
         False,
         self.conf,
     )
     self.processing = False
示例#8
0
 def run(self, w, init_path, repostype, strFolder):
     # Creating our own gmap
     self.gmap = mapServices.MapServ(init_path, repostype)
     self.complete = []
     self.downloader = MapDownloader(self.gmap)
     if self.conf.map_service in NO_BULK_DOWN:
         if not legal_warning(self, self.conf.map_service,
                              "bulk downloading"):
             self.all_done("Canceled")
             return
     args = MapArgs()
     if self.processing: return
     try:
         args.lat = float(self.e_lat0.get_text())
         args.lng = float(self.e_lon0.get_text())
         args.width = float(self.e_kmx.get_text())
         args.height = float(self.e_kmy.get_text())
         args.min_zl = self.s_zoom0.get_value_as_int()
         args.max_zl = self.s_zoom1.get_value_as_int()
         layer = self.layer
     except ValueError:
         d = gtk.MessageDialog(self, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
                               gtk.BUTTONS_CLOSE,
                               "Some field contain non-numbers")
         d.run()
         d.destroy()
         return
     self.b_pause.set_sensitive(True)
     self.b_download.set_sensitive(False)
     self.b_open.set_sensitive(False)
     # Save the map info
     self.save_info(check_dir(strFolder), str(args))
     self.pbar.set_text(" ")
     self.processing = True
     self.downloader.bulk_download(
         (args.lat, args.lng, 15),
         (args.min_zl, args.max_zl), args.width, args.height, layer,
         gui_callback(self.tile_received), self.download_complete, False,
         self.conf)
     self.processing = False
示例#9
0
    def read(self):
        def read_config(keyOption, defaultValue, castFunction):
            try:
                strValue = config.get(SECTION_INIT, keyOption)
                return castFunction(strValue)
            except Exception:
                return defaultValue

        config = ConfigParser.RawConfigParser()
        config.read(self.config_path)

        ## Initial window width, default is 550
        self.init_width = read_config('width', 550, int)
        ## Initial window height, default is 450
        self.init_height = read_config('height', 450, int)
        ## Initial map zoom, default is MAP_MAX_ZOOM_LEVEL-1
        self.init_zoom = read_config('zoom', MAP_MAX_ZOOM_LEVEL-1, int)
        ## Initial map center, default is ((1,0), (9,200))
        self.init_center = read_config('center', ((1,0),(9,200)), str_to_tuple)

        ## Directory path to the map images, default is "userProfile" folder
        self.init_path = DEFAULT_PATH
        strPath = read_config('path', self.init_path, str)
        if not strPath.strip().lower() in ['none', '']:
            strPath = fileUtils.check_dir(strPath)
            if os.path.isdir(strPath):
                self.init_path = strPath

        ## Repository type - filebased / sqlite3
        self.repository_type =  read_config('repository_type', 0, int)

        ## How often is the GPS updated, default is 1 second
        self.gps_update_rate = read_config('gps_update_rate', 1.0, float)
        ## Show a small cross in the center of the map, default is False (0)
        self.show_cross = read_config('show_cross', 0, int)
        ## Maximum zoom to show the GPS, default is 16
        self.max_gps_zoom = read_config('max_gps_zoom', 16, int)
        ## default increment for gps track saving
        self.gps_increment = read_config('gps_increment', GPS_INCREMENT, int)
        ## Map service to get images, default is Yahoo
        self.map_service = read_config('map_service', MAP_SERVERS[YAHOO], str)
        ## URL with the latest version used for the notification updates.
        self.version_url = read_config('version_url',
            'http://gmapcatcher.googlecode.com/svn/wiki/version.wiki', str)
        ## Whether or not to check for updates, default is True (1)
        self.check_for_updates = read_config('check_for_updates', 1, int)
        ## Initial GPS mode, default is GPS_DISABLED
        self.gps_mode = read_config('gps_mode', GPS_DISABLED, int)
        ## Initial style ID for the CloudMade maps
        self.cloudMade_styleID = read_config('cloudmade_styleid', 1, int)
        ## language setting, default is 'en'
        self.language = read_config('language', 'en', str)
        ## oneDirPerMap setting, default is False
        self.oneDirPerMap = read_config('oneDirPerMap', 0, int)
        ## status setting, default is STATUS_NONE
        self.status_location = read_config('status_location', 0, int)
        ## save width/height/layer/location at close, default is SAVE_AT_CLOSE
        self.save_at_close = read_config('save_at_close', 1, int)
        ## layer when saved at close
        self.save_layer = read_config('save_layer', LAYER_MAP, int)
        ## location when saved at close
        self.save_hlocation = read_config('save_hlocation', 0, int)
        self.save_vlocation = read_config('save_vlocation', 0, int)
        ## width when saved at close
        self.save_width = read_config('save_width', 550, int)
        ## height when saved at close
        self.save_height = read_config('save_height', 450, int)
        ## should scale be visible
        self.scale_visible = read_config('scale_visible', 1, int)
        ## auto-refresh frequency in miliseconds
        self.auto_refresh = read_config('auto_refresh', 0, int)
        ## Amount of days used when user selects the Force Update
        self.force_update_days = read_config('force_update_days', 1, int)
        ## Part of the URL that is used to get the google tiles
        self.google_src = read_config('google_src', '', str)
        ## The match function to be used in the auto-completion of the entry
        self.match_func = read_config('match_func', ENTRY_SUB_MENU[0], str)
        ## Show the name/description of the marker in the map
        self.show_marker_name = read_config('show_marker_name', 0, int)
        print 
示例#10
0
 def get_configpath(self):
     # the config file must be found at DEFAULT_PATH
     configpath = DEFAULT_PATH
     fileUtils.check_dir(configpath)
     configpath = os.path.join(configpath, 'gmapcatcher.conf')
     return configpath
示例#11
0
 def get_configpath(self):
     # the config file must be found at DEFAULT_PATH
     configpath = DEFAULT_PATH
     fileUtils.check_dir(configpath)
     configpath = os.path.join(configpath, 'gmapcatcher.conf')
     return configpath
示例#12
0
    def read(self):
        def read_config(keyOption,
                        defaultValue,
                        castFunction,
                        section=SECTION_INIT):
            try:
                strValue = config.get(section, keyOption)
                return castFunction(strValue)
            except Exception:
                return defaultValue

        config = ConfigParser.RawConfigParser()
        config.read(self.config_path)

        ## Initial window width, default is 550
        self.init_width = read_config('width', 780, int)
        ## Initial window height, default is 450
        self.init_height = read_config('height', 600, int)

        ## Directory path to the map images, default is "userProfile" folder
        self.init_path = DEFAULT_PATH
        strPath = read_config('path', self.init_path, str)
        if not strPath.strip().lower() in ['none', '']:
            strPath = fileUtils.check_dir(strPath)
            if os.path.isdir(strPath):
                self.init_path = strPath

        ## Repository type - filebased / sqlite3
        self.repository_type = read_config('repository_type', 0, int)
        ## URL with the latest version used for the notification updates.
        self.version_url = read_config(
            'version_url',
            'https://raw.githubusercontent.com/heldersepu/GMapCatcher/wiki/version.md',
            str)
        ## Whether or not to check for updates, default is True (1)
        self.check_for_updates = read_config('check_for_updates', 1, int)
        ## oneDirPerMap setting, default is False
        self.oneDirPerMap = read_config('oneDirPerMap', 0, int)
        ## Statusbar type, default is STATUS_NONE
        self.statusbar_type = read_config('statusbar_type', STATUS_NONE, int)
        ## save width/height/layer/location at close, default is SAVE_AT_CLOSE
        self.save_at_close = read_config('save_at_close', 1, int)
        ## layer when saved at close
        self.save_layer = read_config('save_layer', LAYER_MAP, int)
        ## location when saved at close
        self.save_hlocation = read_config('save_hlocation', 0, int)
        self.save_vlocation = read_config('save_vlocation', 0, int)
        ## width when saved at close
        self.save_width = read_config('save_width', 780, int)
        ## height when saved at close
        self.save_height = read_config('save_height', 600, int)
        ## The match function to be used in the auto-completion of the entry
        self.match_func = read_config('match_func', ENTRY_SUB_MENU[0], str)
        ## List of map servers to hide
        self.hide_map_servers = read_config('hide_map_servers',
                                            '0,3,16,18,19,20', str)
        ## Speed and distance units (default km / km/h)
        self.units = read_config('units', 0, int)
        ## Start offline (default = Yes)
        self.start_offline = read_config('start_offline', 1, int)
        ## limited capabilities (default = No)
        self.limited = read_config('limited', 0, int)

        ## Initial map zoom, default is MAP_MAX_ZOOM_LEVEL-2
        self.init_zoom = read_config('zoom', MAP_MAX_ZOOM_LEVEL - 2, int,
                                     SECTION_MAP)
        ## language setting, default is 'en'
        self.language = read_config('language', 'en', str, SECTION_MAP)
        ## Initial map center, default is ((1, 1), (210, 170))
        self.init_center = read_config('center', ((1, 1), (210, 170)),
                                       str_to_tuple, SECTION_MAP)
        ## Show a small cross in the center of the map, default is False (0)
        self.show_cross = read_config('show_cross', 0, int, SECTION_MAP)
        ## Map service to get images, default is Nokia
        self.map_service = read_config('map_service', MAP_SERVERS[NOKIA], str,
                                       SECTION_MAP)
        ## cloudMade API key
        self.cloudMade_API = read_config('cloudmade_api',
                                         '333d990d389d5e65a7714dd738b2fc77',
                                         str, SECTION_MAP)
        ## Initial style ID for the CloudMade maps
        self.cloudMade_styleID = read_config('cloudmade_styleid', 1, int,
                                             SECTION_MAP)
        ## Visibility of the scale
        self.scale_visible = read_config('scale_visible', 1, int, SECTION_MAP)
        ## Amount of days used when user selects the Force Update
        self.force_update_days = read_config('force_update_days', 1, int,
                                             SECTION_MAP)
        ## auto-refresh frequency in miliseconds
        self.auto_refresh = read_config('auto_refresh', 0, int, SECTION_MAP)
        ## Part of the URL that is used to get the google tiles
        self.google_src = read_config('google_src', '', str, SECTION_MAP)
        ## Show the name/description of the marker in the map
        self.show_marker_name = read_config('show_marker_name', 0, int,
                                            SECTION_MAP)
        ## The font color for the name of the marker
        self.marker_font_color = read_config('marker_font_color', '#00CCCC',
                                             str, SECTION_MAP)
        ## The font Description for the marker "sans bold 12"
        ## http://www.pygtk.org/docs/pygtk/class-pangofontdescription.html
        self.marker_font_desc = read_config('marker_font_desc', 'normal', str,
                                            SECTION_MAP)
        ## Maximum number of threads to download maps
        self.maxthreads = read_config('maxthreads', 4, int, SECTION_MAP)
        ## Time delay before drawing the map overlay
        self.overlay_delay = read_config('overlay_delay', 0.1, float,
                                         SECTION_MAP)
        ## Initial map opacity
        self.opacity = read_config('opacity', 0.0, float, SECTION_MAP)
        ## Initial map opacity
        self.draw_track_start_end = read_config('draw_track_start_end', 0, int,
                                                SECTION_MAP)
        ## Ruler-track width, default is 3px
        self.ruler_track_width = read_config('ruler_track_width', 3, int,
                                             SECTION_MAP)

        ## How often is the GPS updated, default is 1 second
        self.gps_update_rate = read_config('gps_update_rate', 1.0, float,
                                           SECTION_GPS)
        ## default increment for gps track saving
        self.gps_increment = read_config('gps_increment', GPS_INCREMENT, int,
                                         SECTION_GPS)
        ## GPS-type, GPSd (0) or serial (1), default is GPSd
        self.gps_type = read_config('gps_type', 0, int, SECTION_GPS)
        ## Draw GPS-track, default is 1 (True)
        self.gps_track = read_config('gps_track', 1, int, SECTION_GPS)
        ## GPS-track "interval" in meters, default is 50m
        self.gps_track_interval = read_config('gps_track_interval', 50, int,
                                              SECTION_GPS)
        ## GPS-track width, default is 2px
        self.gps_track_width = read_config('gps_track_width', 2, int,
                                           SECTION_GPS)
        ## GPS serial port, default is 'none'
        self.gps_serial_port = read_config('gps_serial_port', 'none', str,
                                           SECTION_GPS)
        ## GPS serial baudrate, default is 9600
        self.gps_serial_baudrate = read_config('gps_serial_baudrate', 9600,
                                               int, SECTION_GPS)
        ## Initial GPS mode, default is GPS_DISABLED
        self.gps_mode = read_config('gps_mode', GPS_DISABLED, int, SECTION_GPS)
        ## Maximum zoom to show the GPS, default is 16
        self.max_gps_zoom = read_config('max_gps_zoom', 16, int, SECTION_GPS)

        ## User agent name
        self.name = read_config('name', NAME, str, SECTION_AGENT)
        ## User agent version
        self.version = read_config('version', VERSION, str, SECTION_AGENT)
        ## User agent webaddress
        self.web_address = read_config('web_address', WEB_ADDRESS, str,
                                       SECTION_AGENT)
示例#13
0
    def read(self):
        def read_config(keyOption, defaultValue, castFunction, section=SECTION_INIT):
            try:
                strValue = config.get(section, keyOption)
                return castFunction(strValue)
            except Exception:
                return defaultValue

        config = ConfigParser.RawConfigParser()
        config.read(self.config_path)

        ## Initial window width, default is 550
        self.init_width = read_config('width', 780, int)
        ## Initial window height, default is 450
        self.init_height = read_config('height', 600, int)

        ## Directory path to the map images, default is "userProfile" folder
        self.init_path = DEFAULT_PATH
        strPath = read_config('path', self.init_path, str)
        if not strPath.strip().lower() in ['none', '']:
            strPath = fileUtils.check_dir(strPath)
            if os.path.isdir(strPath):
                self.init_path = strPath

        ## Repository type - filebased / sqlite3
        self.repository_type = read_config('repository_type', 0, int)
        ## URL with the latest version used for the notification updates.
        self.version_url = read_config('version_url',
            'http://gmapcatcher.googlecode.com/svn/wiki/version.wiki', str)
        ## Whether or not to check for updates, default is True (1)
        self.check_for_updates = read_config('check_for_updates', 1, int)
        ## oneDirPerMap setting, default is False
        self.oneDirPerMap = read_config('oneDirPerMap', 0, int)
        ## Statusbar type, default is STATUS_NONE
        self.statusbar_type = read_config('statusbar_type', STATUS_NONE, int)
        ## save width/height/layer/location at close, default is SAVE_AT_CLOSE
        self.save_at_close = read_config('save_at_close', 1, int)
        ## layer when saved at close
        self.save_layer = read_config('save_layer', LAYER_MAP, int)
        ## location when saved at close
        self.save_hlocation = read_config('save_hlocation', 0, int)
        self.save_vlocation = read_config('save_vlocation', 0, int)
        ## width when saved at close
        self.save_width = read_config('save_width', 780, int)
        ## height when saved at close
        self.save_height = read_config('save_height', 600, int)
        ## The match function to be used in the auto-completion of the entry
        self.match_func = read_config('match_func', ENTRY_SUB_MENU[0], str)
        ## List of map servers to hide
        self.hide_map_servers = read_config('hide_map_servers', '0,3,16,18,19,20', str)
        ## Speed and distance units (default km / km/h)
        self.units = read_config('units', 0, int)
        ## Start offline (default = Yes)
        self.start_offline = read_config('start_offline', 1, int)
        ## limited capabilities (default = No)
        self.limited = read_config('limited', 0, int)

        ## Initial map zoom, default is MAP_MAX_ZOOM_LEVEL-2
        self.init_zoom = read_config('zoom', MAP_MAX_ZOOM_LEVEL - 2, int, SECTION_MAP)
        ## language setting, default is 'en'
        self.language = read_config('language', 'en', str, SECTION_MAP)
        ## Initial map center, default is ((1, 1), (210, 170))
        self.init_center = read_config('center', ((1, 1), (210, 170)), str_to_tuple, SECTION_MAP)
        ## Show a small cross in the center of the map, default is False (0)
        self.show_cross = read_config('show_cross', 0, int, SECTION_MAP)
        ## Map service to get images, default is Nokia
        self.map_service = read_config('map_service', MAP_SERVERS[NOKIA], str, SECTION_MAP)
        ## cloudMade API key
        self.cloudMade_API = read_config('cloudmade_api', '333d990d389d5e65a7714dd738b2fc77', str, SECTION_MAP)
        ## Initial style ID for the CloudMade maps
        self.cloudMade_styleID = read_config('cloudmade_styleid', 1, int, SECTION_MAP)
        ## Visibility of the scale
        self.scale_visible = read_config('scale_visible', 1, int, SECTION_MAP)
        ## Amount of days used when user selects the Force Update
        self.force_update_days = read_config('force_update_days', 1, int, SECTION_MAP)
        ## auto-refresh frequency in miliseconds
        self.auto_refresh = read_config('auto_refresh', 0, int, SECTION_MAP)
        ## Part of the URL that is used to get the google tiles
        self.google_src = read_config('google_src', '', str, SECTION_MAP)
        ## Show the name/description of the marker in the map
        self.show_marker_name = read_config('show_marker_name', 0, int, SECTION_MAP)
        ## The font color for the name of the marker
        self.marker_font_color = read_config('marker_font_color', '#00CCCC', str, SECTION_MAP)
        ## The font Description for the marker "sans bold 12"
        ## http://www.pygtk.org/docs/pygtk/class-pangofontdescription.html
        self.marker_font_desc = read_config('marker_font_desc', 'normal', str, SECTION_MAP)
        ## Maximum number of threads to download maps
        self.maxthreads = read_config('maxthreads', 4, int, SECTION_MAP)
        ## Time delay before drawing the map overlay
        self.overlay_delay = read_config('overlay_delay', 0.1, float, SECTION_MAP)
        ## Initial map opacity
        self.opacity = read_config('opacity', 0.0, float, SECTION_MAP)
        ## Initial map opacity
        self.draw_track_start_end = read_config('draw_track_start_end', 0, int, SECTION_MAP)
		## Ruler-track width, default is 3px
        self.ruler_track_width = read_config('ruler_track_width', 3, int, SECTION_MAP)

        ## How often is the GPS updated, default is 1 second
        self.gps_update_rate = read_config('gps_update_rate', 1.0, float, SECTION_GPS)
        ## default increment for gps track saving
        self.gps_increment = read_config('gps_increment', GPS_INCREMENT, int, SECTION_GPS)
        ## GPS-type, GPSd (0) or serial (1), default is GPSd
        self.gps_type = read_config('gps_type', 0, int, SECTION_GPS)
        ## Draw GPS-track, default is 1 (True)
        self.gps_track = read_config('gps_track', 1, int, SECTION_GPS)
        ## GPS-track "interval" in meters, default is 50m
        self.gps_track_interval = read_config('gps_track_interval', 50, int, SECTION_GPS)
        ## GPS-track width, default is 2px
        self.gps_track_width = read_config('gps_track_width', 2, int, SECTION_GPS)
        ## GPS serial port, default is 'none'
        self.gps_serial_port = read_config('gps_serial_port', 'none', str, SECTION_GPS)
        ## GPS serial baudrate, default is 9600
        self.gps_serial_baudrate = read_config('gps_serial_baudrate', 9600, int, SECTION_GPS)
        ## Initial GPS mode, default is GPS_DISABLED
        self.gps_mode = read_config('gps_mode', GPS_DISABLED, int, SECTION_GPS)
        ## Maximum zoom to show the GPS, default is 16
        self.max_gps_zoom = read_config('max_gps_zoom', 16, int, SECTION_GPS)

        ## User agent name
        self.name = read_config('name', NAME, str, SECTION_AGENT)
        ## User agent version
        self.version = read_config('version', VERSION, str, SECTION_AGENT)
        ## User agent webaddress
        self.web_address = read_config('web_address', WEB_ADDRESS, str, SECTION_AGENT)
示例#14
0
    def read(self):
        def read_config(keyOption, defaultValue, castFunction):
            try:
                strValue = config.get(SECTION_INIT, keyOption)
                return castFunction(strValue)
            except Exception:
                return defaultValue

        config = ConfigParser.RawConfigParser()
        config.read(self.config_path)

        ## Initial window width, default is 550
        self.init_width = read_config('width', 550, int)
        ## Initial window height, default is 450
        self.init_height = read_config('height', 450, int)
        ## Initial map zoom, default is MAP_MAX_ZOOM_LEVEL-1
        self.init_zoom = read_config('zoom', MAP_MAX_ZOOM_LEVEL - 1, int)
        ## Initial map center, default is ((1,0), (9,200))
        self.init_center = read_config('center', ((1, 0), (9, 200)),
                                       str_to_tuple)

        ## Directory path to the map images, default is "userProfile" folder
        self.init_path = os.path.join(os.path.expanduser(USER_PATH),
                                      TILES_PATH)
        strPath = read_config('path', self.init_path, str)
        if not strPath.strip().lower() in ['none', '']:
            strPath = fileUtils.check_dir(strPath)
            if os.path.isdir(strPath):
                self.init_path = strPath

        ## Repository type - filebased / sqlite3
        self.repository_type = read_config('repository_type', 0, int)

        ## How often is the GPS updated, default is 1 second
        self.gps_update_rate = read_config('gps_update_rate', 1.0, float)
        ## Show a small cross in the center of the map, default is False (0)
        self.show_cross = read_config('show_cross', 0, int)
        ## Maximum zoom to show the GPS, default is 16
        self.max_gps_zoom = read_config('max_gps_zoom', 16, int)
        ## default increment for gps track saving
        self.gps_increment = read_config('gps_increment', GPS_INCREMENT, int)
        ## Map service to get images, default is Yahoo
        self.map_service = read_config('map_service', MAP_SERVERS[YAHOO], str)
        ## URL with the latest version used for the notification updates.
        self.version_url = read_config(
            'version_url',
            'http://gmapcatcher.googlecode.com/svn/wiki/version.wiki', str)
        ## Whether or not to check for updates, default is True (1)
        self.check_for_updates = read_config('check_for_updates', 1, int)
        ## Initial GPS mode, default is GPS_DISABLED
        self.gps_mode = read_config('gps_mode', GPS_DISABLED, int)
        ## Initial style ID for the CloudMade maps
        self.cloudMade_styleID = read_config('cloudmade_styleid', 1, int)
        ## language setting, default is 'en'
        self.language = read_config('language', 'en', str)
        ## oneDirPerMap setting, default is False
        self.oneDirPerMap = read_config('oneDirPerMap', 0, int)
        ## status setting, default is STATUS_NONE
        self.status_location = read_config('status_location', 0, int)
        ## save width/height/layer/location at close, default is SAVE_AT_CLOSE
        self.save_at_close = read_config('save_at_close', True, bool)
        ## layer when saved at close
        self.save_layer = read_config('save_layer', LAYER_MAP, int)
        ## location when saved at close
        self.save_hlocation = read_config('save_hlocation', 0, int)
        self.save_vlocation = read_config('save_vlocation', 0, int)
        ## width when saved at close
        self.save_width = read_config('save_width', 550, int)
        ## height when saved at close
        self.save_height = read_config('save_height', 450, int)
        ## should scale be visible
        self.scale_visible = read_config('scale_visible', True, int)
        ## auto-refresh frequency in miliseconds
        self.auto_refresh = read_config('auto_refresh', 0, int)
        ## Amount of days used when user selects the Force Update
        self.force_update_days = read_config('force_update_days', 1, int)
        ## Part of the URL that is used to get the google tiles
        self.google_src = read_config('google_src', '', str)
        ## The match function to be used in the auto-completion of the entry
        self.match_func = read_config('match_func', ENTRY_SUB_MENU[0], str)