def getCutList(self):
        cuts = None
        cut_list = []
        file_name = self.serviceref.getPath() + '.cuts'
        if not os.path.exists(file_name):
            return cut_list
        else:
            try:
                cuts = open(file_name, 'rb')
                while 1:
                    data = cuts.read(12)
                    if data == '':
                        break
                    where = struct.unpack('>Q', data[0:8])[0]
                    what = struct.unpack('>I', data[8:12])[0]
                    cut_list.append((long(where), what))

            except:
                print('ERROR reading cutlist', file_name)
                printStackTrace()
            finally:
                if cuts is not None:
                    cuts.close()

            return cut_list
Beispiel #2
0
    def updateMovieList(self, dir_list=None, delay=0):
        print("[AdvancedMovieSelection] Start scanning movies")
        try:
            # print dir_list
            self.isWorking = True
            if delay > 0:
                print("waiting", str(delay))
                import time
                time.sleep(delay)
            self.updateReloadTime()
            if dir_list is None:
                self.movielibrary.clearAll()
                dir_list = self.updateDirectories()

            # print "-" * 80
            # for p in dir_list:
            #    print p
            # print "-" * 80

            for p in dir_list:
                self.scanForMovies(p)

            # self.full_used_detect = self.getFullUsed()
            if self.callback is not None:
                self.callback()

            # from MovieLibrary import dict2xml
            # xml = dict2xml(self.movielibrary)
            # xml.write("/tmp/movie_list.xml")
        except:
            printStackTrace()
        self.isWorking = False
        directories, movies = self.movielibrary.getFullCount()
        print("[AdvancedMovieSelection] Finished scanning movies",
              str(directories), str(movies))
Beispiel #3
0
 def timerStateChanged(self, timer):
     try:
         from timer import TimerEntry
         print "timer.event", timer.name
         print "timer.state", timer.state
         if timer.state == TimerEntry.StateEnded:
             print "TimerEntry", timer.name
             if not timer.Filename:
                 print "cancel, no timer filename"
                 return
             filename = timer.Filename.endswith(
                 ".ts") and timer.Filename or timer.Filename + ".ts"
             print filename
             mi = MovieInfo(timer.name, None, file_name=filename)
             serviceref = mi.createService()
             mi.serviceref = serviceref
             mi.info = self.serviceHandler.info(serviceref)
             mi.begin = mi.info.getInfo(serviceref,
                                        iServiceInformation.sTimeCreate)
             movie_path = os.path.dirname(mi.serviceref.getPath()) + os.sep
             print movie_path
             self.movielibrary.addMovie(movie_path, mi)
             self.updateReloadTime()
             print "add:", mi
     except:
         printStackTrace()
def getDirectories(l, root, hidden=False):
    root = os.path.realpath(root) + os.sep
    if not autoNetwork.isMountOnline(root):
        print "not connected:", root
        return
    if not os.path.exists(root):
        print "path not exists:", root
        return
    if not root in l:
        l.append(root)
    for entry in os.listdir(root):
        try:
            if not hidden and entry.startswith('.'):
                continue
            dir_path = os.path.join(root, entry)
            if not os.path.isdir(dir_path):
                continue
            dir_path = os.path.realpath(dir_path) + os.sep
            # Skip excluded directories here
            if any(item.lower() in dir_path.lower() for item in SCAN_EXCLUDE):
                print "skip folder: \"%s\"" % (dir_path)
                continue
            dvd = detectDVDStructure(dir_path)
            bludisc = detectBludiscStructure(dir_path)
            if dvd or bludisc:
                continue
            if not dir_path in l:
                l.append(dir_path)
            getDirectories(l, dir_path, hidden)
        except:
            printStackTrace()
    def updateMovieList(self, dir_list=None, delay=0):
        print "[AdvancedMovieSelection] Start scanning movies"
        try:
            # print dir_list
            self.isWorking = True
            if delay > 0:
                print "waiting", str(delay)
                import time
                time.sleep(delay)
            self.updateReloadTime()
            if dir_list is None:
                self.database.clearAll()
                dir_list = self.updateDirectories()
            
            # print "-" * 80
            # for p in dir_list:
            #    print p
            # print "-" * 80
            
            for p in dir_list:
                self.scanForMovies(p)
            
            # self.full_used_detect = self.getFullUsed()
            if self.callback is not None:
                self.callback()

            # from MovieDatabase import dict2xml
            # xml = dict2xml(self.database)
            # xml.write("/tmp/movie_list.xml")
        except:
            printStackTrace()
        self.isWorking = False
        directories, movies = self.database.getFullCount()
        print "[AdvancedMovieSelection] Finished scanning movies", str(directories), str(movies)
Beispiel #6
0
    def readPathTable(self, file_name):
        path_table = []
        try:
            f = open(file_name, 'rb')
            block = 16 * ISORead.BLOCK_SIZE
            f.seek(block)
            data = f.read(7)
            vd = VolumeStructureDescriptor(data)
            if vd.type == VolumeStructureDescriptor.TYPE and vd.identifier == self.VOLUME_TYPE_DVD:
                f.seek(block + 132)
                path_table_size = LB32(f.read(8))
                l_path_table = LB32(f.read(4))
                if l_path_table > 0 and path_table_size < self.BLOCK_SIZE:
                    f.seek(l_path_table * self.BLOCK_SIZE)
                    length = 0
                    data = f.read(path_table_size)
                    while length < path_table_size:
                        dr = LPathTableRecord(data[length:])
                        length += dr.length
                        path_table.append(dr.directory)

            f.close()
        except:
            printStackTrace()

        return path_table
 def downloadMovieInfo(self, name, filename=None):
     try:
         from EventInformationTable import createEIT
         print "[AdvancedMovieSelection] RecordTimerEvent, loading info from tmdb:", name
         createEIT(filename, name)
     except:
         printStackTrace()
Beispiel #8
0
    def __init__(self, serviceref):
        self.servicename = ''
        self.description = ''
        self.tags = ''
        self.name = ''
        self.time_create = ''
        try:
            try:
                meta_path = checkCreateMetaFile(serviceref)
            except Exception as e:
                print(str(e))
                if os.path.isfile(serviceref.getPath()):
                    self.name = os.path.basename(
                        serviceref.getPath()).split('.')[0]
                else:
                    self.name = serviceref.getName()
                return

            if meta_path is not None and os.path.exists(meta_path):
                meta_file = open(meta_path, 'r')
                meta_file.readline()
                self.name = meta_file.readline().rstrip('\r\n')
                self.description = meta_file.readline().rstrip('\r\n')
                self.time_create = meta_file.readline().rstrip('\r\n')
                self.tags = meta_file.readline().rstrip('\r\n')
                meta_file.close()
        except Exception as e:
            print('Exception in load meta data: ' + str(e))
            printStackTrace()

        return
Beispiel #9
0
def getDirectories(l, root, hidden=False):
    root = os.path.realpath(root) + os.sep
    if not autoNetwork.isMountOnline(root):
        print("not connected:", root)
        return
    if not os.path.exists(root):
        print("path not exists:", root)
        return
    if not root in l:
        l.append(root)
    for entry in os.listdir(root):
        try:
            if not hidden and entry.startswith('.'):
                continue
            dir_path = os.path.join(root, entry)
            if not os.path.isdir(dir_path):
                continue
            dir_path = os.path.realpath(dir_path) + os.sep
            # Skip excluded directories here
            if any(item.lower() in dir_path.lower() for item in SCAN_EXCLUDE):
                print("skip folder: \"%s\"" % (dir_path))
                continue
            dvd = detectDVDStructure(dir_path)
            bludisc = detectBludiscStructure(dir_path)
            if dvd or bludisc:
                continue
            if not dir_path in l:
                l.append(dir_path)
            getDirectories(l, dir_path, hidden)
        except:
            printStackTrace()
def checkDVDCuts(fileName):
    cuts_file = None
    cut_list = []
    if not os.path.exists(fileName + '.cuts'):
        return False
    else:
        try:
            cuts_file = open(fileName + '.cuts', 'rb')
            while 1:
                data = cuts_file.read(12)
                if data == '':
                    break
                where = struct.unpack('>Q', data[0:8])[0]
                what = struct.unpack('>I', data[8:12])[0]
                print(what, where)
                cut_list.append((where, what))
                title = struct.unpack('<i', cuts_file.read(4))[0:4][0]
                chapter = struct.unpack('<i', cuts_file.read(4))[0:4][0]
                block = struct.unpack('<I', cuts_file.read(4))[0:4][0]
                audio_id = struct.unpack('<i', cuts_file.read(4))[0:4][0]
                audio_lock = struct.unpack('<i', cuts_file.read(4))[0:4][0]
                spu_id = struct.unpack('<i', cuts_file.read(4))[0:4][0]
                spu_lock = struct.unpack('<i', cuts_file.read(4))[0:4][0]
                what = struct.unpack('>i', cuts_file.read(4))[0:4][0]
                print('py_resume_pos: resume_info.title=%d, chapter=%d, block=%d, audio_id=%d, audio_lock=%d, spu_id=%d, spu_lock=%d  (pts=%d)' % (title, chapter, block, audio_id, audio_lock, spu_id, spu_lock, what))
                if what == 4:
                    return True

        except:
            printStackTrace()
        finally:
            if cuts_file is not None:
                cuts_file.close()

        return False
Beispiel #11
0
 def downloadMovieInfo(self, name, filename=None):
     try:
         from EventInformationTable import createEIT
         print "[AdvancedMovieSelection] RecordTimerEvent, loading info from tmdb:", name
         createEIT(filename, name)
     except:
         printStackTrace()
 def write(self, file_name):
     try:
         xmlstr = self.doc.toprettyxml() #self.doc.toxml('utf-8')
         f = open(file_name, 'w')
         f.write(xmlstr)
         f.close()        
     except:
         printStackTrace()
Beispiel #13
0
 def write(self, file_name):
     try:
         xmlstr = self.doc.toprettyxml()  #self.doc.toxml('utf-8')
         f = open(file_name, 'w')
         f.write(xmlstr)
         f.close()
     except:
         printStackTrace()
Beispiel #14
0
 def updateOldVersion(self):
     try:
         print("update older config version")
         self.setFunction('red', config.AdvancedMovieSelection.red.value)
         self.setFunction('green', config.AdvancedMovieSelection.green.value)
         self.setFunction('yellow', config.AdvancedMovieSelection.yellow.value)
         self.setFunction('blue', config.AdvancedMovieSelection.blue.value)
         print(self.qlist)
     except:
         printStackTrace()
Beispiel #15
0
 def updateOldVersion(self):
     try:
         print "update older config version"
         self.setFunction('red', config.AdvancedMovieSelection.red.value)
         self.setFunction('green', config.AdvancedMovieSelection.green.value)
         self.setFunction('yellow', config.AdvancedMovieSelection.yellow.value)
         self.setFunction('blue', config.AdvancedMovieSelection.blue.value)
         print self.qlist
     except:
         printStackTrace()
Beispiel #16
0
 def umount(self):
     try:
         cmd = 'umount -df "%s"' % ISOInfo.MOUNT_PATH
         print('exec command:', cmd)
         out = commands.getoutput(cmd)
         if out:
             print('error:', out)
         return not out
     except:
         printStackTrace()
         return False
Beispiel #17
0
 def umount(self):
     try:
         cmd = "umount -df \"%s\"" % (ISOInfo.MOUNT_PATH)
         print "exec command:", cmd
         out = commands.getoutput(cmd)
         if out:
             print "error:", out
         return not out
     except:
         printStackTrace()
         return False
 def downloadMovieInfo(self, download_type, name, description, filename):
     try:
         if not filename.endswith(".ts"):
             filename += ".ts"
         if download_type == "tmdb_movie":
             eitFromTMDb(filename, name)
         if download_type == "tmdb_serie":
             #downloadTMDbSerie(filename, name)
             downloadTMDbEpisode(filename, name, description)
         if download_type == "tvdb_serie":
             createEITtvdb(filename, name)
     except:
         printStackTrace()
 def timerStateChanged(self, timer):
     try:
         print "[AdvancedMovieSelection] timer state changed event"
         print str(timer.justplay), str(timer.cancelled), str(timer.state) 
         if timer.justplay:
             print "[AdvancedMovieSelection] cancel justplay event"
             return
         if not hasattr(timer, 'Filename'):
             print "[AdvancedMovieSelection] cancel timer state changed, no Filename in timer event"
             return
         for callback in self.on_state_changed:
             callback(timer)
     except:
         printStackTrace()
Beispiel #20
0
 def updateHotplugDevices(self):
     self.hotplugServices = []
     print "[update hutplug]"
     try:
         import commands
         movieConfig = MovieConfig()
         lines = commands.getoutput('mount | grep /dev/sd').split('\n')
         print lines
         for mount in lines:
             if len(mount) < 2:
                 continue
             dev = mount.split(' on ')[0].strip()
             m = mount.split(' type')[0].split(' on ')
             m_dev, m_path = m[0], m[1]
             label = os.path.split(m_path)[-1]
             blkid = commands.getoutput('blkid ' + m_dev).split("\"")
             #if len(blkid) > 2 and blkid[1]:
             #    label = blkid[1]
             if "LABEL" in blkid:
                 label = blkid.split("LABEL=")[1].split(" ")[0].strip()
             if os.path.normpath(m_path) == "/media/hdd" or label in ("DUMBO", "TIMOTHY"):
                 continue
             if not movieConfig.isHiddenHotplug(label):
                 blkdev = BlockDevice(dev)
                 if m_path[-1] != "/":
                     m_path += "/"
                 
                 #print blkdev.isRemovable()
                 #print blkdev.name()
                 #print blkdev.capacityString()
                 if not blkdev.isRemovable():
                     continue
                 
                 service = eServiceReferenceHotplug(m_path)
                 devname = m_dev.replace("/dev/", "")[:-1]
                 filename = str.format("/sys/block/{0}/device/block/{0}/device/model", devname)
                 #model = commands.getoutput("cat " + filename)
                 model = Util.readFile(filename)
                 if label:
                     label += " - "
                 service.setName(label + model + " - " + blkdev.capacityString())
                 self.hotplugServices.append(service)
         
         for callback in self.notifier:
             try:
                 callback()
             except:
                 printStackTrace()
     except:
         printStackTrace()
Beispiel #21
0
 def __read(self, dir_path):
     try:
         if os.path.exists(self.meta_file):
             metafile = open(self.meta_file, "r")
             self.name = metafile.readline().rstrip()
             self.sort_type = self.__parse_int(metafile)
             self.used = self.__parse_int(metafile)
             self.dir_size = self.__parse_int(metafile)
             self.dir_count = self.__parse_int(metafile)
             self.mov_count = self.__parse_int(metafile)
             #self.rest = metafile.read()
             metafile.close()
     except:
         printStackTrace()
 def __read(self, dir_path):
     try:
         if os.path.exists(self.meta_file):
             metafile = open(self.meta_file, "r")
             self.name = metafile.readline().rstrip()
             self.sort_type = self.__parse_int(metafile)
             self.used = self.__parse_int(metafile)
             self.dir_size = self.__parse_int(metafile)
             self.dir_count = self.__parse_int(metafile)
             self.mov_count = self.__parse_int(metafile)
             #self.rest = metafile.read()
             metafile.close()
     except:
         printStackTrace()
 def setCutList(self, cut_list):
     cuts = None
     try:
         file_name = self.serviceref.getPath() + ".cuts"
         cuts = open(file_name, "wb")
         for where, what in cut_list:
             data = struct.pack('>Q', where)
             cuts.write(data)
             data = struct.pack('>I', what)
             cuts.write(data)
     except Exception, e:
         print "ERROR writing cutlist", file_name
         printStackTrace()
         return e
 def updateDiskUsage(self, dir_count=None, movie_count=None):
     #mount = self.getmount()
     #if not mount:
     #    return
     try:
         if self.isDiskSpaceChanged():
             self.updateFolderSize()
             if dir_count is not None:
                 self.dir_count = dir_count
             if movie_count is not None:
                 self.mov_count = movie_count
             #self.write()
     except:
         printStackTrace()
Beispiel #25
0
 def updateDiskUsage(self, dir_count=None, movie_count=None):
     #mount = self.getmount()
     #if not mount:
     #    return
     try:
         if self.isDiskSpaceChanged():
             self.updateFolderSize()
             if dir_count is not None:
                 self.dir_count = dir_count
             if movie_count is not None:
                 self.mov_count = movie_count
             #self.write()
     except:
         printStackTrace()
Beispiel #26
0
 def timerStateChanged(self, timer):
     try:
         print "[AdvancedMovieSelection] timer state changed event"
         print str(timer.justplay), str(timer.cancelled), str(timer.state)
         if timer.justplay:
             print "[AdvancedMovieSelection] cancel justplay event"
             return
         if not hasattr(timer, 'Filename'):
             print "[AdvancedMovieSelection] cancel timer state changed, no Filename in timer event"
             return
         for callback in self.on_state_changed:
             callback(timer)
     except:
         printStackTrace()
Beispiel #27
0
 def mount(self, iso):
     self.umount()
     try:
         if not os.path.exists(self.MOUNT_PATH):
             print "Creating mount path for bludisc iso on:", self.MOUNT_PATH
             os.mkdir(self.MOUNT_PATH)
         cmd = "mount -r -o loop \"%s\" \"%s\"" % (iso, self.MOUNT_PATH)
         print "exec command:", cmd
         out = commands.getoutput(cmd)
         if out:
             print "error:", out
         return not out
     except:
         printStackTrace()
         return False
Beispiel #28
0
 def mount(self, iso):
     self.umount()
     try:
         if not os.path.exists(self.MOUNT_PATH):
             print('Creating mount path for bludisc iso on:',
                   self.MOUNT_PATH)
             os.mkdir(self.MOUNT_PATH)
         cmd = 'mount -r -o loop "%s" "%s"' % (iso, self.MOUNT_PATH)
         print('exec command:', cmd)
         out = commands.getoutput(cmd)
         if out:
             print('error:', out)
         return not out
     except:
         printStackTrace()
         return False
Beispiel #29
0
class ServiceInfo:
    def __init__(self, serviceref):
        self.servicename = ""
        self.description = ""
        self.tags = ""
        self.name = ""
        self.time_create = ""
        try:
            meta_path = None
            try:
                meta_path = checkCreateMetaFile(serviceref)
            except Exception, e:
                print e
            if meta_path is None:
                if os.path.isfile(serviceref.getPath()):
                    self.name = os.path.splitext(
                        os.path.basename(serviceref.getPath()))[0]
                else:
                    self.name = serviceref.getName()
                return

            if meta_path is not None and os.path.exists(meta_path):
                meta_file = open(meta_path, "r")
                meta_file.readline()
                self.name = meta_file.readline().rstrip("\r\n")
                self.description = meta_file.readline().rstrip("\r\n")
                self.time_create = meta_file.readline().rstrip("\r\n")
                self.tags = meta_file.readline().rstrip("\r\n")
                meta_file.close()
        except Exception, e:
            print "Exception in load meta data: " + str(e)
            printStackTrace()
def loadBackup(file_name):
    print "load backup", file_name
    backup = open(file_name, 'rb')
    for line in backup.readlines():
        try:
            config_entry = line.split(".")[1]
            config_item = line.split(".")[2].split("=")[0]
            value = line.split("=")[-1].strip()
            print config_entry, config_item, value
            entry = config.content.items[config_entry]
            conf = entry.__getattr__(config_item)
            conf.saved_value = conf._value = value
            conf.load()
        except:
            printStackTrace()
    backup.close()
def createBackup(path="/media/hdd/"):
    changes = []
    for item in CONFIG_BACKUP:
        getChanges(item, changes)

    import os
    file_name = os.path.join(path, BACKUP_FILE_NAME)
    print "create backup", file_name
    try:
        backup = open(file_name, 'wb')
        backup.write("\n".join(changes))
        backup.close()
    except:
        printStackTrace()
        return
    return file_name
Beispiel #32
0
def loadBackup(file_name):
    print "load backup", file_name 
    backup = open(file_name, 'rb')
    for line in backup.readlines():
        try:
            config_entry = line.split(".")[1]
            config_item = line.split(".")[2].split("=")[0]
            value = line.split("=")[-1].strip()
            print config_entry, config_item, value
            entry = config.content.items[config_entry]
            conf = entry.__getattr__(config_item)
            conf.saved_value = conf._value = value
            conf.load()
        except:
            printStackTrace()
    backup.close()
Beispiel #33
0
def createBackup(path="/media/hdd/"):
    changes = []
    for item in CONFIG_BACKUP:
        getChanges(item, changes)

    import os
    file_name = os.path.join(path, BACKUP_FILE_NAME)
    print "create backup", file_name
    try: 
        backup = open(file_name, 'wb')
        backup.write("\n".join(changes))
        backup.close()
    except:
        printStackTrace()
        return
    return file_name
Beispiel #34
0
def getPercentSeen(serviceref):
    cuts = serviceref.getPath() + ".cuts"
    if serviceref.type == eServiceReference.idDVB:
        meta = serviceref.getPath() + ".meta"
    else:
        meta = serviceref.getPath() + ".ts.meta"

    length = 0
    last = 0
    perc = 0
    f = None
    if not os.path.exists(cuts) or not os.path.exists(meta):
        return 0
    try:
        f = open(cuts, "rb")
        while 1:
            data = f.read(12)
            if data == '':
                break
            what = struct.unpack('>I', data[8:12])[0]
            if what == InfoBarCueSheetSupport.CUT_TYPE_LAST:
                where = struct.unpack('>Q', data[0:8])[0]
                last = long(where) / 90000
            if what == InfoBarCueSheetSupport.CUT_TYPE_OUT:
                where = struct.unpack('>Q', data[0:8])[0]
                length = long(where) / 90000
        f.close()

        if last > 0 and length == 0:
            f = open(meta, "rb")
            lines = f.readlines()
            if len(lines) > 5:
                length = long(lines[5]) / 90000

        if last > 0 and length > 0:
            perc = int((float(last) / length) * 100)
            if perc > 100:
                perc = 100
            if perc < 0:
                perc = 0
    except:
        printStackTrace()
    finally:
        if f is not None:
            f.close()
    return perc
    def getTimerEntryDownloadType(self, timer):
        try:
            if hasattr(timer, 'plugins'):
                ams_timer = timer.plugins.get("AMS_COVER_DOWNLOAD")
                print "timer.plugins", str(ams_timer)
                if ams_timer is not None:
                    download = ams_timer[0]
                    print download
                    return download

            print "no timer.plugins!!!"
            default = config.AdvancedMovieSelection.timer_download_type.value
            if default:
                print "timer_download_type:", str(default)
            return default
        except:
            printStackTrace()
Beispiel #36
0
 def timerStateChanged(self, timer):
     try:
         from timer import TimerEntry
         print "timer.event", timer.name
         print "timer.state", timer.state
         if timer.state == TimerEntry.StateRunning:
             print "TimerEntry", timer.name
             print timer.Filename + ".ts"
             mi = MovieInfo(timer.name, None, file_name=timer.Filename + ".ts")
             serviceref = mi.createService()
             mi.info = self.serviceHandler.info(serviceref)
             mi.begin = mi.info.getInfo(serviceref, iServiceInformation.sTimeCreate)
             movie_path = os.path.dirname(mi.serviceref.getPath()) + os.sep
             self.movielibrary.addMovie(movie_path, mi)
             self.updateReloadTime()
             print "add:", mi
     except:
         printStackTrace()
 def timerStateChanged(self, timer):
     try:
         from timer import TimerEntry 
         print "timer.event", timer.name
         print "timer.state", timer.state
         if timer.state == TimerEntry.StateRunning:
             print "TimerEntry", timer.name
             print timer.Filename + ".ts"
             mi = MovieInfo(timer.name, None, file_name=timer.Filename + ".ts")
             serviceref = mi.createService()
             mi.info = self.serviceHandler.info(serviceref)
             mi.begin = mi.info.getInfo(serviceref, iServiceInformation.sTimeCreate)
             movie_path = os.path.dirname(mi.serviceref.getPath()) + os.sep
             self.database.addMovie(movie_path, mi)
             self.updateReloadTime()
             print "add:", mi
     except:
         printStackTrace()
 def write(self):
     if self.meta_file == '/.meta':
         print "[AdvancedMovieSelection] Write new meta skipped"
         return
     metafile = None
     try:
         print "[AdvancedMovieSelection] Write new meta:", self.meta_file, self.sort_type, self.used
         metafile = open(self.meta_file, "w")
         metafile.write(str(self.name) + '\n')
         metafile.write(str(self.sort_type) + '\n')
         #metafile.write(str(self.used) + '\n')
         #metafile.write(str(self.dir_size) + '\n')
         #metafile.write(str(self.dir_count) + '\n')
         #metafile.write(str(self.mov_count) + '\n')
         metafile.close()
     except:
         printStackTrace()
         if metafile is not None:
             metafile.close()
 def write(self):
     if self.meta_file == '/.meta':
         print("[AdvancedMovieSelection] Write new meta skipped")
         return
     metafile = None
     try:
         print("[AdvancedMovieSelection] Write new meta:", self.meta_file, self.sort_type, self.used)
         metafile = open(self.meta_file, "w")
         metafile.write(str(self.name) + '\n')
         metafile.write(str(self.sort_type) + '\n')
         #metafile.write(str(self.used) + '\n')
         #metafile.write(str(self.dir_size) + '\n')
         #metafile.write(str(self.dir_count) + '\n')
         #metafile.write(str(self.mov_count) + '\n')
         metafile.close()
     except:
         printStackTrace()
         if metafile is not None:
             metafile.close()
    def setCutList(self, cut_list):
        cuts = None
        try:
            file_name = self.serviceref.getPath() + '.cuts'
            cuts = open(file_name, 'wb')
            for where, what in cut_list:
                data = struct.pack('>Q', where)
                cuts.write(data)
                data = struct.pack('>I', what)
                cuts.write(data)

        except Exception as e:
            print('ERROR writing cutlist', file_name)
            printStackTrace()
            return e
        finally:
            if cuts is not None:
                cuts.close()

        return
Beispiel #41
0
    def updateHotplugDevices(self):
        self.hotplugServices = []
        print("[update hutplug]")
        try:
            from Components.Harddisk import Harddisk
            try:
                import commands
            except:
                import subprocess as commands
            movieConfig = MovieConfig()
            lines = commands.getoutput('mount | grep /dev/sd').split('\n')
            print(lines)
            for mount in lines:
                if len(mount) < 2:
                    continue
                m = mount.split(' type')[0].split(' on ')
                m_dev, m_path = m[0], m[1]
                label = os.path.split(m_path)[-1]
                blkid = commands.getoutput('blkid ' + m_dev).split("\"")
                if len(blkid) > 2 and blkid[1]:
                    label = blkid[1]
                if os.path.normpath(m_path) == "/media/hdd" or label in ("DUMBO", "TIMOTHY"):
                    continue
                if not movieConfig.isHiddenHotplug(label):
                    if m_path[-1] != "/":
                        m_path += "/"
                    service = eServiceReferenceHotplug(m_path)
                    hdd = Harddisk(m_dev.replace("/dev/", "")[:-1])
                    if label:
                        label += " - "
                    service.setName(label + hdd.model() + " - " + hdd.capacity())
                    self.hotplugServices.append(service)

            for callback in self.notifier:
                try:
                    callback()
                except:
                    printStackTrace()
        except:
            printStackTrace()
Beispiel #42
0
 def updateHotplugDevices(self):
     self.hotplugServices = []
     print "[update hutplug]"
     try:
         from Components.Harddisk import Harddisk
         import commands
         movieConfig = MovieConfig()
         lines = commands.getoutput('mount | grep /dev/sd').split('\n')
         print lines
         for mount in lines:
             if len(mount) < 2:
                 continue
             m = mount.split(' type')[0].split(' on ')
             m_dev, m_path = m[0], m[1]
             label = os.path.split(m_path)[-1]
             blkid = commands.getoutput('blkid ' + m_dev).split("\"")
             if len(blkid) > 2 and blkid[1]:
                 label = blkid[1]
             if os.path.normpath(m_path) == "/media/hdd" or label in ("DUMBO", "TIMOTHY"):
                 continue
             if not movieConfig.isHiddenHotplug(label):
                 if m_path[-1] != "/":
                     m_path += "/"
                 service = eServiceReferenceHotplug(m_path)
                 hdd = Harddisk(m_dev.replace("/dev/", "")[:-1])
                 if label:
                     label += " - "
                 service.setName(label + hdd.model() + " - " + hdd.capacity())
                 self.hotplugServices.append(service)
         
         for callback in self.notifier:
             try:
                 callback()
             except:
                 printStackTrace()
     except:
         printStackTrace()
def loadSkin(name, scope=SCOPE_SKIN):
    # read the skin
    filename = resolveFilename(scope, name)
    mpath = os.path.dirname(filename) + "/"
    skins = []
    skins.append((mpath, xml.etree.cElementTree.parse(filename).getroot()))
    skins.reverse()
    for (path, dom_skin) in skins:
        loadSingleSkinData(dom_skin, path)


try:
    loadSkin(config.skin.primary_skin.value)
except:
    printStackTrace()

skin_colors = sorted(skin_colors, key=lambda x: (x[1], x[1]))
for col in skin_colors:
    if checkColor(col[0], color_choice):
        color_choice.append(col)

config.AdvancedMovieSelection.color1 = ConfigSelection(
    default=color_choice[0][0], choices=color_choice)
config.AdvancedMovieSelection.color2 = ConfigSelection(
    default=color_choice[0][0], choices=color_choice)
config.AdvancedMovieSelection.color3 = ConfigSelection(
    default=color_choice[0][0], choices=color_choice)
config.AdvancedMovieSelection.color4 = ConfigSelection(
    default=color_choice[0][0], choices=color_choice)
config.AdvancedMovieSelection.color5 = ConfigSelection(