Beispiel #1
0
 def onFileAction(self):
     
     try:
         x = openFile(self.session, guess_type(self.SOURCELIST.getFilename())[0], self.SOURCELIST.getCurrentDirectory() + self.SOURCELIST.getFilename())
         print 'RESULT OPEN FILE', x
     except TypeError:
         e = None
         print 'ok'
Beispiel #2
0
 def onFileAction(self):
     try:
         x = openFile(self.session,guess_type(self.SOURCELIST.getFilename())[0],self.SOURCELIST.getCurrentDirectory()+self.SOURCELIST.getFilename())
         print "RESULT OPEN FILE",x
     except TypeError,e:
         # catching error
         #  File "/home/tmbinc/opendreambox/1.5/dm8000/experimental/build/tmp/work/enigma2-2.6git20090627-r1/image/usr/lib/enigma2/python/Components/Scanner.py", line 43, in handleFile
         #  TypeError: 'in <string>' requires string as left operand
         self.session.open(MessageBox,_("no Viewer installed for this mimetype!"), type = MessageBox.TYPE_ERROR, timeout = 5, close_on_any_key = True)
Beispiel #3
0
	def onFileAction(self, dirsource, dirtarget):
		self.SOURCELIST = dirsource
		self.TARGETLIST = dirtarget
		filename = dirsource.getFilename()
		self.SOURCELIST = dirsource
		self.TARGETLIST = dirtarget
		sourceDir = dirsource.getCurrentDirectory()
		if not sourceDir.endswith("/"):
			sourceDir = sourceDir + "/"
		testFileName = filename.lower()
		filetype = testFileName.split('.')
		filetype = "." + filetype[-1]
		longname = sourceDir + filename
		print "[Filebrowser]: " + filename, sourceDir, testFileName
		if testFileName.endswith(".ipk"):
			self.session.openWithCallback(self.onFileActionCB, ipkMenuScreen, self.SOURCELIST, self.TARGETLIST)
		elif testFileName.endswith(".ts"):
			fileRef = eServiceReference("1:0:0:0:0:0:0:0:0:0:" + longname)
			self.session.open(MoviePlayer, fileRef)
		elif testFileName.endswith(tuple(MOVIE_EXTENSIONS)):
			fileRef = eServiceReference("4097:0:0:0:0:0:0:0:0:0:" + longname)
			self.session.open(MoviePlayer, fileRef)
		elif testFileName.endswith(tuple(DVD_EXTENSIONS)):
			if DVDPlayerAvailable:
				self.session.open(DVD.DVDPlayer, dvd_filelist=[longname])
		elif testFileName.endswith(tuple(AUDIO_EXTENSIONS)):
			self.play_music(self.SOURCELIST)
		elif (testFileName.endswith(".rar")) or (re.search('\.r\d+$', filetype)):
			self.session.openWithCallback(self.onFileActionCB, RarMenuScreen, self.SOURCELIST, self.TARGETLIST)
		elif (testFileName.endswith(".gz")) or (testFileName.endswith(".tar")):
			self.session.openWithCallback(self.onFileActionCB, TarMenuScreen, self.SOURCELIST, self.TARGETLIST)
		elif (testFileName.endswith(".zip")):
			self.session.openWithCallback(self.onFileActionCB, UnzipMenuScreen, self.SOURCELIST, self.TARGETLIST)
		elif testFileName.endswith(tuple(IMAGE_EXTENSIONS)):
			if self.SOURCELIST.getSelectionIndex()!=0:
				self.session.openWithCallback(self.cbShowPicture, 
							      ImageViewer, 
							      self.SOURCELIST.getFileList(), 
					  		    self.SOURCELIST.getSelectionIndex(), 
					      		self.SOURCELIST.getCurrentDirectory(),
					      		filename)
		elif testFileName.endswith(".sh"):
			self.run_script(self.SOURCELIST)
		elif testFileName.endswith(".txt") or testFileName.endswith(".log") or testFileName.endswith(".py") or testFileName.endswith(".xml") or testFileName.endswith(".html") or testFileName.endswith(".meta") or testFileName.endswith(".bak") or testFileName.endswith(".lst") or testFileName.endswith(".cfg"):
			xfile=os_stat(longname)
#			if (xfile.st_size < 61440):
			if (xfile.st_size < 1000000):
				self.session.open(vEditor, longname)
				self.onFileActionCB(True)
		else:
			try:
				x = openFile(self.session,guess_type(self.SOURCELIST.getFilename())[0],self.SOURCELIST.getCurrentDirectory()+self.SOURCELIST.getFilename())
			except TypeError,e:
				self.session.open(MessageBox,_("no Viewer installed for this mimetype!"), type = MessageBox.TYPE_ERROR, timeout = 5, close_on_any_key = True)
	def openCallback(self, res):
		from Components.Scanner import openFile

		# Try to open file if res was True
		if res and not openFile(self.session, None, self.filename):
			self.session.open(
				MessageBox,
				_("No suitable Viewer found!"),
				type = MessageBox.TYPE_ERROR,
				timeout = 5
			)

		# Calback with Filename on success
		if self.callback is not None:
			self.callback(self.filename)

		self.close()
Beispiel #5
0
 def onFileAction(self, dirsource, dirtarget):
     self.SOURCELIST = dirsource
     self.TARGETLIST = dirtarget
     filename = dirsource.getFilename()
     self.SOURCELIST = dirsource
     self.TARGETLIST = dirtarget
     sourceDir = dirsource.getCurrentDirectory()
     if not sourceDir.endswith("/"):
         sourceDir = sourceDir + "/"
     testFileName = filename.lower()
     filetype = os.path.splitext(testFileName)[1]
     longname = sourceDir + filename
     print "[Filebrowser]:", filename, sourceDir, testFileName
     if not fileExists(longname):
         self.session.open(MessageBox,
                           _("File not found: %s") % longname,
                           type=MessageBox.TYPE_ERROR)
         return
     if filetype == ".ipk":
         self.session.openWithCallback(self.onFileActionCB, ipkMenuScreen,
                                       self.SOURCELIST, self.TARGETLIST)
     elif filetype == ".ts":
         fileRef = eServiceReference(eServiceReference.idDVB,
                                     eServiceReference.noFlags, longname)
         self.session.open(MoviePlayer, fileRef)
     elif filetype in MOVIE_EXTENSIONS:
         fileRef = eServiceReference(eServiceReference.idServiceMP3,
                                     eServiceReference.noFlags, longname)
         self.session.open(MoviePlayer, fileRef)
     elif filetype in DVD_EXTENSIONS:
         if DVDPlayerAvailable:
             self.session.open(DVD.DVDPlayer, dvd_filelist=[longname])
     elif filetype in AUDIO_EXTENSIONS:
         self.play_music(self.SOURCELIST)
     elif filetype == ".rar" or re.search('\.r\d+$', filetype):
         self.session.openWithCallback(self.onFileActionCB, RarMenuScreen,
                                       self.SOURCELIST, self.TARGETLIST)
     elif testFileName.endswith(".tar.gz") or filetype in (".tgz", ".tar"):
         self.session.openWithCallback(self.onFileActionCB, TarMenuScreen,
                                       self.SOURCELIST, self.TARGETLIST)
     elif filetype == ".gz":  # Must follow test for .tar.gz
         self.session.openWithCallback(self.onFileActionCB,
                                       GunzipMenuScreen, self.SOURCELIST,
                                       self.TARGETLIST)
     elif filetype == ".zip":
         self.session.openWithCallback(self.onFileActionCB, UnzipMenuScreen,
                                       self.SOURCELIST, self.TARGETLIST)
     elif filetype in IMAGE_EXTENSIONS:
         if self.SOURCELIST.getSelectionIndex() != 0:
             self.session.openWithCallback(
                 self.cbShowPicture, ImageViewer,
                 self.SOURCELIST.getFileList(),
                 self.SOURCELIST.getSelectionIndex(),
                 self.SOURCELIST.getCurrentDirectory(), filename)
     elif filetype == ".sh":
         self.run_script(self.SOURCELIST)
     elif filetype in TEXT_EXTENSIONS:
         try:
             xfile = os.stat(longname)
         except OSError as oe:
             self.session.open(MessageBox,
                               _("%s: %s") % (longname, oe.strerror),
                               type=MessageBox.TYPE_ERROR)
             return
         # if (xfile.st_size < 61440):
         if (xfile.st_size < 1000000):
             self.session.open(vEditor, longname)
             self.onFileActionCB(True)
     else:
         try:
             found_viewer = openFile(self.session,
                                     guess_type(longname)[0], longname)
         except TypeError, e:
             found_viewer = False
         if not found_viewer:
             self.session.open(
                 MessageBox,
                 _("No viewer installed for this file type: %s") % filename,
                 type=MessageBox.TYPE_ERROR,
                 timeout=5,
                 close_on_any_key=True)
Beispiel #6
0
 def onFileAction(self, dirsource, dirtarget):
     filename = dirsource.getFilename()
     self.SOURCELIST = dirsource
     self.TARGETLIST = dirtarget
     sourceDir = dirsource.getCurrentDirectory()
     if not sourceDir.endswith("/"):
         sourceDir = sourceDir + "/"
     testFileName = filename.lower()
     filetype = os.path.splitext(testFileName)[1]
     longname = sourceDir + filename
     print("[Filebrowser]:", filename, sourceDir, testFileName)
     if not fileExists(longname):
         self.session.open(MessageBox,
                           _("File not found: %s") % longname,
                           type=MessageBox.TYPE_ERROR)
         return
     if filetype == ".ipk":
         self.session.openWithCallback(self.onFileActionCB, ipkMenuScreen,
                                       self.SOURCELIST, self.TARGETLIST)
     elif filetype == ".ts":
         fileRef = eServiceReference(eServiceReference.idDVB,
                                     eServiceReference.noFlags, longname)
         self.session.open(MoviePlayer, fileRef)
     elif filetype in MOVIE_EXTENSIONS:
         fileRef = eServiceReference(eServiceReference.idServiceMP3,
                                     eServiceReference.noFlags, longname)
         self.session.open(MoviePlayer, fileRef)
     elif filetype in DVD_EXTENSIONS:
         if DVDPlayerAvailable:
             self.session.open(DVD.DVDPlayer, dvd_filelist=[longname])
     elif filetype in AUDIO_EXTENSIONS:
         self.play_music(self.SOURCELIST)
     elif filetype == ".rar" or re.search('\.r\d+$', filetype):
         self.session.openWithCallback(self.onFileActionCB, RarMenuScreen,
                                       self.SOURCELIST, self.TARGETLIST)
     elif testFileName.endswith(".tar.gz") or filetype in (".tgz", ".tar"):
         self.session.openWithCallback(self.onFileActionCB, TarMenuScreen,
                                       self.SOURCELIST, self.TARGETLIST)
     elif filetype == ".gz":  # Must follow test for .tar.gz
         self.session.openWithCallback(self.onFileActionCB,
                                       GunzipMenuScreen, self.SOURCELIST,
                                       self.TARGETLIST)
     elif filetype == ".zip":
         self.session.openWithCallback(self.onFileActionCB, UnzipMenuScreen,
                                       self.SOURCELIST, self.TARGETLIST)
     elif filetype in IMAGE_EXTENSIONS:
         if self.SOURCELIST.getSelectionIndex() != 0:
             self.session.openWithCallback(
                 self.cbShowPicture, ImageViewer,
                 self.SOURCELIST.getFileList(),
                 self.SOURCELIST.getSelectionIndex(),
                 self.SOURCELIST.getCurrentDirectory(), filename)
     elif filetype in (".sh", ".py", ".pyo"):
         self.run_script(self.SOURCELIST, self.TARGETLIST)
     elif filetype == ".mvi":
         self.file_name = longname
         self.tmp_file = '/tmp/grab_%s_mvi.png' % filename[:-4]
         choice = [(_("No"), "no"),
                   (_("Show as Picture (press any key to close)"), "show")]
         savetext = ''
         stat = os.statvfs('/tmp/')
         if stat.f_bavail * stat.f_bsize > 1000000:
             choice.append((_("Show as Picture and save as file ('%s')") %
                            self.tmp_file, "save"))
             savetext = _(" or save additional the picture to a file")
         self.session.openWithCallback(
             self.mviFileCB,
             MessageBox,
             _("Show '%s' as picture%s?\nThe current service must interrupted!"
               ) % (longname, savetext),
             simple=True,
             list=choice)
     elif filetype in TEXT_EXTENSIONS or config.plugins.filecommander.unknown_extension_as_text.value:
         try:
             xfile = os.stat(longname)
         except OSError as oe:
             self.session.open(MessageBox,
                               _("%s: %s") % (longname, oe.strerror),
                               type=MessageBox.TYPE_ERROR)
             return
         if (xfile.st_size < 1000000):
             self.session.open(vEditor, longname)
             self.onFileActionCB(True)
     else:
         try:
             found_viewer = openFile(self.session,
                                     guess_type(longname)[0], longname)
         except TypeError as e:
             found_viewer = False
         if not found_viewer:
             self.session.open(
                 MessageBox,
                 _("No viewer installed for this file type: %s") % filename,
                 type=MessageBox.TYPE_ERROR,
                 timeout=5,
                 close_on_any_key=True)