Permalink
Browse files

add default config, read from config

  • Loading branch information...
1 parent 3d8ba70 commit 80aed54b6050ef89d97657e85f56239d625d868c Shenja Sosna committed Sep 6, 2011
Showing with 16 additions and 241 deletions.
  1. +9 −237 configuration.py
  2. +7 −4 torent_check.py
View
@@ -21,13 +21,13 @@
this code copied from Mehdi Abaakouk <theli48@gmail.com> via Listen, 2006 Mehdi AbaakoukGimmie (c)
License: GPLv2
"""
-import gobject
from xdg.BaseDirectory import xdg_config_home, xdg_data_home
#from xdg_support import get_xdg_config_file
from ConfigParser import RawConfigParser as ConfigParser
import logging
-#logging.c
-CONFIG_FOLDER = join(xdg_config_home, "gomodoro")
+logging.getLogger("TorrentCheck")
+
+CONFIG_FOLDER = join(xdg_config_home, "torrentcheck")
VERSION_CONFIG=1
class Config():
@@ -55,6 +55,7 @@ def load(self):
def update_config(self):
version = self.get("setting","version", "")
if not version:
+ logging.debug("not version")
#self.set("wikipedia","lang", self.get("wikipedia","lang").replace("<###>",";"))
self.set("setting","version",VERSION_CONFIG)
self.write()
@@ -70,14 +71,13 @@ def get(self,section,option,default=None):
def set(self,section,option,value):
if not self._config.has_section(section):
- self.logdebug("Section \"%s\" not exist, create...", section)
+ logging.debug("Section \"%s\" not exist, create...", section)
self._config.add_section(section)
self._config.set(section,option,value)
#Dispatcher.config_change(section,option,value)
- self.emit("config-changed",section,option,value)
def write(self):
- filename = get_xdg_config_file("config")
+ filename = CONFIG_FOLDER
f = file(filename, "w")
self._config.write(f)
f.close()
@@ -91,237 +91,9 @@ def __get_default(self):
},
"setting":
{
- "start_trayicon": "false",
- "fermer_trayicon": "false",
- "use_trayicon": "true",
- "update_title": "true",
- "media_organizer_item" : "0",
- "repeat_mode":"false",
- "shuffle_mode":"false",
- "wikipedia":"en",
- "empty_random":"false",
- "web_font":"Sans 12",
- "web_color_text":"#000000",
- "web_color_link":"#C09665",
- "web_color_bg":"#FFFFFF",
- "web_font":"Sans 12",
- "notification" : "true",
- "compact_playlist" : "false",
- "dynamic_playlist_color": "false",
- "offline" : "false",
- "use_local_cover" : "false"
- },
- "dynamic_mode":{
- "expanded":"false",
- "enable":"false",
- "remove_played":"true",
- "track_append":"2",
- "track_upcoming":"10",
- "played_show":"3",
- },
- "library":
- {
-# "location":"",
- "watcher":"false",
- "startup_deleted":"false",
- "startup_added":"false",
- },
- "osd":
- {
- "enable": "false",
- "osd_custom_position": "-1 -1",
- "osd_colors": "#ffffff #ffffff #ffffff #2959ac",
- "osd_font": "Sans 18",
- "osd_timeout": "7.5",
- "osd_transparency": "215",
- "osd_center_x": "1",
- "osd_center_y": "0",
- },
- "audioscrobbler":
- {
- "enable":"false",
- "url":"post.audioscrobbler.com",
- "username":"",
- "password":""
- },
- "lyrics":
- {
- "server":"lyrc.com.ar"
- },
- "player":
- {
- "volume":"1.0",
- "play_on_startup":"false",
- "play":"false",
- "crossfade":"true",
- "crossfade_gapless_album":"false",
- "crossfade_time":"3.0",
- "enqueue":"false",
- "click_enqueue":"false",
- "queuewholealbum":"false",
- "dynamic":"true",
- "vis":"goom",
- "stop_track":"-1",
- "uri":"",
- "state":"stop",
- "seek":"0",
- "selected_track":"-1"
- },
- "window":
- {
- "width" : "860",
- "height" : "530",
- "x" : "-1",
- "y" : "-1",
- "state" : "widthdrawn",
- "pos_organizer" : "130",
- "pos_global_pane" : "270",
- "pos_cur_playlist" : "500",
- "view":"2",
- "right_layout":"false"
- },
- "source":
- {
- "selected_index":"('0','1')",
- },
- "filebrowser":{
- "pane_pos":"200",
- "uri":"file:///home"
- },
- "browser":
- {
- "view":"0",
- "local_num_cols":"3",
-
- "podcast_local_num_cols" : "1",
-
- "jamendo_num_cols":"3",
-
- "jamendo" : "true",
- "jamendo_last_search":"",
- "jamendo_pos":"120",
- "jamendo_sort_tag":"",
- "jamendo_sort_order":"",
-
- "local" : "true",
- "local_last_search":"",
- "local_pos":"120",
- "local_sort_tag":"",
- "local_sort_order":"",
-
- "podcast_local" : "true",
- "podcast_local_last_search":"",
- "podcast_local_pos":"120",
- "podcast_local_sort_tag":"",
- "podcast_local_sort_order":"",
-
- "daap" : "true",
- "daap_last_search":"",
- "daap_pos":"120",
- "daap_sort_tag":"",
- "daap_sort_order":"",
- "ipod" : "true",
- "ipod_last_search":"",
- "ipod_pos":"120",
- "ipod_sort_tag":"",
- "ipod_sort_order":"",
- "podcast_ipod" : "true",
- "podcast_ipod_last_search":"",
- "podcast_ipod_pos":"120",
- "podcast_ipod_sort_tag":"",
- "podcast_ipod_sort_order":"",
- "filesystem_sort_tag":"",
- "filesystem_sort_order":"",
- "radio_sort_tag":"",
- "radio_sort_order":"",
- "lastfmradio_sort_tag":"",
- "lastfmradio_sort_order":"",
- "favoriteradio_sort_tag":"",
- "favoriteradio_sort_order":"",
- "audiocd_sort_tag":"",
- "audiocd_sort_order":"",
- },
- "song_view": {
- "filesystem_artist":"true",
- "filesystem_artist_order":"1",
- "filesystem_artist_width":"100"
- },
- "podcast":
- {
- "startup":"true",
- "time_refresh":"120",
- "folder":"~/Podcasts",
- "nb_download":"5"
- },
- "iradio":
- {
- "shoutcast_pos":"170"
- },
- "webservice":
- {
- "filter":"bo<###>ost<###>cd1<###>cd2<###>cd3<###>cd 1<###>cd 2<###>cd 3<###> - <###>(<###>)"
- },
- "wikipedia":
- {
- "lang":"en;fr;de;es;it;nl;sv;pl;pt",
- "info":"0"
- },
- "song_editor":
- {
- "width":"476",
- "height":"308"
- },
- "id3": {
- "num0_frame2":"",
- "num0_frame":"TALB",
- "num0_label":_("Album"),
- "num0_tag":"album",
- "num1_frame2":"",
- "num1_frame":"TCOM",
- "num1_label":_("Composer"),
- "num1_tag":"composer",
- "num2_frame2":"",
- "num2_frame":"TCON",
- "num2_label":_("Genre"),
- "num2_tag":"genre",
- "num3_frame2":"",
- "num3_frame":"TDRC",
- "num3_label":_("Year"),
- "num3_tag":"date",
- "num4_frame2":"",
- "num4_frame":"TEXT",
- "num4_label":_("Lyricist"),
- "num4_tag":"lyricist",
- "num5_frame2":"",
- "num5_frame":"TIT2",
- "num5_label":_("Title"),
- "num5_tag":"title",
- "num6_frame2":"",
- "num6_frame":"TIT3",
- "num6_label":_("Version"),
- "num6_tag":"version",
- "num7_frame2":"",
- "num7_frame":"TPE1",
- "num7_label":_("Artist"),
- "num7_tag":"artist",
- "num8_frame2":"TPE1",
- "num8_frame":"TXXX:ALBUM ARTIST",
- "num8_label":_("Album Artist"),
- "num8_tag":"album artist",
- "num9_frame2":"",
- "num9_frame":"TRCK",
- "num9_label":_("#"),
- "num9_tag":"#track"
- },
- "font": {
- "browser_size":"10",
- "library_size":"8"
- },
- "plugins": {
- "active_genericmanager":"Brasero",
- "active_webradiomanager":"Shoutcast",
- "active_sourcemanager":"\n".join(["yooook","Last.fm events","Lastfm Information","Context","Filesystem Browser","Web Radio support"]),
- }
+ "username": "pumbaEO",
+ "password": "password",
+ }
}
View
@@ -13,13 +13,15 @@
import gettext
from gettext import gettext as _
gettext.textdomain('diffsamizdat')
-logging.getLogger()
-
+logging.getLogger("TorrentCheck")
+from configuration import config
+'''
post_params = urllib.urlencode({
'login_username' : LOGIN,
'login_password' : PASS,
'login' : '%C2%F5%EE%E4'
})
+'''
class BaseHtmlParser(sgmllib.SGMLParser):
@@ -56,8 +58,8 @@ def get_data(self):
class TorrentCheck:
def __init__(self):
- LOGIN = 'login'
- PASS = 'pass'
+ LOGIN = config.get("setting","username")
+ PASS = config.get("setting","password")
self.post_params = urllib.urlencode({
'login_username' : LOGIN,
'login_password' : PASS,
@@ -116,6 +118,7 @@ def main():
if options.debug_mode:
options.logging_level = 3
logging.basicConfig(level=LEVELS[options.logging_level], format='%(lineno)d %(asctime)s %(levelname)s %(message)s')
+ config.load()
t = TorrentCheck()
return

0 comments on commit 80aed54

Please sign in to comment.