def __init__(self, par): ## reference to pyjama self.parent = par ## pyjama's home directory self.home = functions.preparedirs() ## pyjama's database file self.db = os.path.join(self.home, "pyjama.db") self.tracks, self.albums, self.artists = 0, 0, 0 self.query_counter = 0 ## stores results for threaded queries self.results = {} # not implemented, yet self.queue = [] ## holds the connection to our database self.connection = None self.open() self.database_ok = True if not os.path.exists(os.path.join(functions.preparedirs(), "pyjama.db")): self.database_ok = False else: sql = "select count(name) from sqlite_master where name = 'albums' or name = 'artists' or name = 'tracks'" try: tablecount = self.__query(sql) if tablecount[0][0] < 3: print ("Some tables in the database seems to be missing, found only %i tables" % tablecount[0][0]) print ("Marking the database as corrupt") self.database_ok = False except Exception: self.database_ok = False if self.database_ok: try: ## number of tracks in the database self.tracks = self.__query("SELECT COUNT (*) FROM tracks WHERE 1")[0][0] ## number of albums in the database self.albums = self.__query("SELECT COUNT (*) FROM albums WHERE 1")[0][0] ## number of artists in the database self.artists = self.__query("SELECT COUNT (*) FROM artists WHERE 1")[0][0] except TypeError, inst: self.database_ok = False desc = "\n\n+-------------------------------------------------------+\n" desc += "| A neccessary table wasn't found. |\n" desc += "| Pyjama will now download and convert the needed files |\n" desc += "| If any problems occur, run 'pyjama -u' |\n" desc += "+-------------------------------------------------------+" # self.parent.Events.raise_event("error", inst, desc) print desc # sys.exit(1) if self.tracks < 135000 or self.albums < 19000 or self.artists < 10000: print ("There seem to be a lot of entries missing in the database") print ("Marking the database as corrupt") self.database_ok = False
def __init__(self, pyjama): self.pyjama = pyjama self.home = functions.preparedirs() self.install_dir = functions.install_dir() self.pyjama.dump_tools.download_fkt = self.download self.pyjama.set_download_database_fkt(self.auto_download) self.pyjama.Events.connect_event("dbtools_message", self.ev_message) self.pyjama.Events.connect_event("alldone", self.ev_alldone)
def __init__(self, pyjama): ## Reference to pyjama self.pyjama = pyjama ## Database file self.db = os.path.join(functions.preparedirs(), "settings.db") ## Holds the databse connection self.connection = None self.query_counter = 0 if not os.path.exists(self.db): self.open() self.create_database() else: self.open()
def __init__(self, pyjama): self.pyjama = pyjama self.home = functions.preparedirs() self.firstrun = False self.release = None self.file = None self.remote_version = None self.curpage = "http://xn--ngel-5qa.de/pvc.html" self.progress = 0 self.pyjama.Events.connect_event("alldone", self.ev_alldone) self.pyjama.Events.connect_event("alldone", self.ev_firstrun)
def __init__(self, pyjama): self.__pyjama = pyjama self.__home = functions.preparedirs() gtk.VBox.__init__(self) # self.set_size(700,400) # self.__pyjama.Events.connect_event("scrolled_window_resized", self.ev_scrolled_window_resized) # might be obsolet # self.__pyjama.window.setcolor(self) self.all_artistsinfos = [] self.widgets = {} self.cur_page = 1 self.cur_firstletter = "0-9" self.resultsperpage = 10
def __init__(self, pyjama): self.pyjama = pyjama self.torrents_to_serve = int(self.pyjama.settings.get_value("TORRENT", "number_of_torrents", 10, float)) self.format = self.pyjama.settings.get_value("TORRENT", "torrent_format", "both") #mp3 both ogg self.old_torrents = self.pyjama.settings.get_value("TORRENT", "old_torrents", 1) #0 - 5 (spread, ignore, delete, upload only, download only) self.quit = False self.window = None self.torrentdir = os.path.join(functions.preparedirs(), "torrent") if not os.path.exists(self.torrentdir): try: os.mkdir(self.torrentdir) except Exception, inst: print ("Could not create %s" % self.torrentdir) raise
def prepare_browser(self): self.pyjama.preferences.register_plugin("Mozplug", self.create_preferences, self.save_preferences) profdir = os.path.join(self.home, "mozplug") profile = "default" prefsPath = os.path.join(profdir, profile, "prefs.js") self.pyjama.Events.connect_event("showing_artist_page", self.ev_artistpage) self.pyjama.Events.connect_event("showing_album_page", self.ev_albumpage) prefsContent = """ user_pref("browser.link.open_newwindow", 1); user_pref("browser.link.open_newwindow.restriction", 0); user_pref("browser.link.open_external", 1); user_pref("capability.policy.default.Window.open", "noAccess"); user_pref("security.warn_entering_secure", false); user_pref("security.warn_entering_weak", false); user_pref("security.warn_viewing_mixed", false); user_pref("security.warn_leaving_secure", false); user_pref("security.warn_submit_insecure", false); user_pref("security.warn_entering_secure.show_once", false); user_pref("security.warn_entering_weak.show_once", false); user_pref("security.warn_viewing_mixed.show_once", false); user_pref("security.warn_leaving_secure.show_once", false); user_pref("security.warn_submit_insecure.show_once", false); user_pref("security.enable_java", true); user_pref("browser.xul.error_pages.enabled", false); user_pref("general.useragent.vendor", "%s"); user_pref("general.useragent.vendorSub", "%s"); user_pref("general.useragent.vendorComment", "%s"); user_pref("modules.plugins.mimetype.application/x-shockwave-flash", ""); """ % ( "Pyjama", self.pyjama.version, "Python Jamendo Audioplayer", ) if os.path.exists(os.path.join(self.home, "mozplug", "default")) == False: os.makedirs(os.path.join(self.home, "mozplug", "default")) functions.preparedirs(set_privilegs=True) f = open(prefsPath, "wt") f.write(prefsContent) f.close() self.mozillaWidget = gtkmozembed.MozEmbed() gtkmozembed.set_profile_path(profdir, profile) self.mozillaWidget.connect("location", self.ev_location_changed) self.mozillaWidget.connect("link_message", self.ev_link_message) self.mozillaWidget.connect("new-window", self.ev_new_window) self.mozillaWidget.connect("progress", self.ev_progress) self.mozillaWidget.show() toolbar = gtk.Toolbar() toolbar.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR) toolbar.set_style(gtk.TOOLBAR_BOTH_HORIZ) toolbar.show() ## Back-button self.back = gtk.ToolButton() # x.set_label("") # home.set_is_important(True) self.back.set_stock_id(gtk.STOCK_GO_BACK) self.back.set_tooltip_text("Show previous page") self.back.connect("clicked", self.cb_toolbutton_clicked, "back") toolbar.insert(self.back, -1) self.back.show() ## Home-button home = gtk.ToolButton() # x.set_label("") # home.set_is_important(True) home.set_stock_id(gtk.STOCK_HOME) home.set_tooltip_text("View Jamendo's start page") home.connect("clicked", self.cb_toolbutton_clicked, "home") toolbar.insert(home, -1) home.show() ## forward-button self.forward = gtk.ToolButton() # x.set_label("") # home.set_is_important(True) self.forward.set_stock_id(gtk.STOCK_GO_FORWARD) self.forward.set_tooltip_text("Show next page in history") self.forward.connect("clicked", self.cb_toolbutton_clicked, "fwd") toolbar.insert(self.forward, -1) self.forward.show() ## address bar self.addressbar = gtk.ToolItem() self.addressbar.entry = gtk.Entry() self.addressbar.entry.set_size_request(300, -1) self.addressbar.entry.connect("key-press-event", self.cb_entry_keypress) self.addressbar.add(self.addressbar.entry) self.addressbar.entry.show() self.addressbar.show() toolbar.insert(self.addressbar, -1) ## go-button self.go = gtk.ToolButton() # x.set_label("") # home.set_is_important(True) self.go.set_stock_id(gtk.STOCK_OK) self.go.set_tooltip_text("Navigate to this page") self.go.connect("clicked", self.cb_toolbutton_clicked, "go") toolbar.insert(self.go, -1) self.go.show() ## Space space_fs = gtk.ToolItem() space_fs.set_expand(True) toolbar.insert(space_fs, -1) space_fs.show() ## Hide-button x = gtk.ToolButton() x.set_label("Hide this browser") x.set_is_important(True) x.set_stock_id(gtk.STOCK_GO_DOWN) x.set_tooltip_text("Hide this browser again") x.connect("clicked", self.cb_toolbutton_clicked, "hide") toolbar.insert(x, -1) x.show() self.frame = gtk.Frame(FRAME_STRING) self.frame.show() self.vbox = gtk.VBox(False) self.vbox.pack_start(toolbar, False, True) self.vbox.pack_start(self.mozillaWidget, True, True) self.statusbar = WebStatusBar() self.statusbar.show() self.vbox.pack_start(self.statusbar, False, False) self.frame.add(self.vbox)
def __init__(self, pyjama): self.pyjama = pyjama self.home = functions.preparedirs() self.pyjama.Events.connect_event("alldone", self.ev_alldone)
def run(options): ## Check some playback options if options.xmlrpc_playpause: xmlrpc(PLAYPAUSE) return elif options.xmlrpc_next: xmlrpc(NEXT) return elif options.xmlrpc_prev: xmlrpc(PREV) return elif options.xmlrpc_playing: xmlrpc(PLAYING) return if options.version: print (functions.VERSION) return None home = functions.preparedirs(set_privilegs=True) if "check-modules" in sys.argv: return None if options.cache_long: directory = os.path.join(home, "cache", "long") files = os.listdir(directory) for f in files: os.remove(os.path.join(directory, f)) print ("Deleted all cache-entries for long-time-cache") if options.cache_short: directory = os.path.join(home, "cache", "short") files = os.listdir(directory) for f in files: os.remove(os.path.join(directory, f)) print ("Deleted all cache-entries for short-time-cache") # if len(sorteddirlist()) == 0: # options.downloadthemes = True if options.downloadthemes: # IMPROVE THIS from modules import get_themepack ret = get_themepack.download_pack() if ret == 0: #pass options.listhemes = True else: return None #~ if options.downloadimages: #~ # IMPROVE THIS #~ from modules import get_imagepack #~ ret = get_imagepack.download_pack() #~ if ret == 0: #~ # no error #~ pass #~ else: #~ print ("An error occured") #~ print ("You can try again running 'pyjama -i'") if not os.path.exists(os.path.join(home, "pyjama.db")): print ("forcing update - no database found") options.update = True if options.listhemes: dirs = functions.sorteddirlist() counter = 1 if len(dirs) == 0: print ("No themes installed") print ("You can get some by running 'pyjama -p'") else: print ("Following Themes were found:") for directory in dirs: print ("%i) %s" % (counter, directory)) counter += 1 return None val = settings.get_value("PYJAMA", "standard_theme") if val == "None" or val == None or val[0] == "#": if not options.theme or options.theme=="None": options.nocolor=True if not options.nocolor and not options.theme: options.theme = val if options.theme and not options.nocolor: ret, theme = functions.showtheme(options.theme) if ret == None: print ("Loaded theme '%s'") % theme else: print (ret) return None win = clWindow.winGTK(options) try: #~ gtk.gdk.threads_enter() gtk.main() #~ gtk.gdk.threads_leave() except KeyboardInterrupt: win.main.quit() print (".... bye!") sys.exit(0)
!Please also check, if you meet all dependencies! Especially the module 'simplejson' needs to be installed. ---""" printbox(txt) sys.exit(1) ## @endcond # Gettext - Übersetzung functions.translation_gettext() #def _(string): # return string home = functions.preparedirs() ## get a settings instance to get default themes ... settings = clSettings.settings(None) # Check if a m3u is given as a param # see clMain.py line 550ff # not implemented, yet since I cannot deduce froum # stream URL to track-id #for arg in sys.argv: # if arg.endswith(".m3u"): # # check if another pyjama instance is running. # # Since xmlrpc seems to be somehow instable for # # me, i will use the methode below # dest = os.path.join(home, "jamendo-playlist.m3u") # try: # shutil.copy(arg, dest)