def getImageThumb(self, data): if not isImage(data[9]): iconsPath = "/usr/share/icons/gnome/32x32/mimetypes/" defaultIcon = iconsPath + "empty.png" iconName = "gnome-mime-"+data[9].split('/')[0].lower()+"-"+data[9].split('/')[-1].lower()+".png" if os.path.exists(iconsPath+iconName): pixbuf = gtk.gdk.pixbuf_new_from_file(iconsPath+iconName) else: pixbuf = gtk.gdk.pixbuf_new_from_file(defaultIcon) image = gtk.Image() image.set_from_pixbuf(pixbuf) return image cachePath = getPyShareHomeDirectory() + 'cache/' if not os.path.exists(cachePath): os.makedirs(cachePath) #filename = cachePath + md5(data[6].join(data[5])).hexdigest() #if os.path.exists(filename): pixbuf = getThumbnailFromCache(data[2]) if pixbuf : image = gtk.Image() image.set_from_pixbuf(pixbuf) return image else: pixbuf = self.getImageFromHosting(data) filename=cachePath + md5(data[2]).hexdigest() image = gtk.Image() image.set_from_pixbuf(pixbuf) if(data[8]=="jpg" or data[8]=="gif"): pixbuf.save(filename, "jpeg") else: pixbuf.save(filename, data[8]) return image
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os import datetime import pickle import sqlite3 from helpers.gnomeHelper import getPyShareHomeDirectory from Singleton import Singleton historypathfile = getPyShareHomeDirectory()+"pyshare.db" class DB(): __metaclass__ = Singleton def __init__(self): if not os.path.exists(historypathfile): self.createDbFile() self.createCursor() self.addInitialData() else: self.connection=sqlite3.connect(historypathfile,check_same_thread=False) self.createCursor() def createDbFile(self):
-errorCallback is called if anything bad happen -plugins are running in their own threads -log errors -number of concurrent uploads is not exceeded Do note that this module is not a security sandbox (fe: malicious plugin stil can delete home folder)""" from threading import Thread from sys import exc_info from plugins.libs.cliHelper import printLink, printProgressToCLI from Settings import Settings import logging from helpers.gnomeHelper import getPyShareHomeDirectory LOG_PATH = getPyShareHomeDirectory() + 'errorLog' logging.basicConfig(filename=LOG_PATH, level=logging.DEBUG) logger1 = logging.getLogger('pluginWrapper') def __runMethod(method, arguments,errorCallback,errorCallbackArgument): """runs method and catches all exceptions errorCallback function will be called if Exception occurs""" try: apply(method, arguments) except: excInfo = exc_info() logger1.exception(excInfo[1]) errorCallback(errorCallbackArgument)