def renameCallback(self, newName = None):
		if not newName:
			return

		if self.currlist == "remote":
			absRemoteFile, fileName, fileSize = self.getRemoteFile()
			if not fileName:
				return

			directory = self["remote"].getCurrentDirectory()
			sep = '/' if directory != '/' else ''
			newRemoteFile = directory + sep + newName

			def callback(ret = None):
				AddPopup(_("Renamed %s to %s.") % (fileName, newName), MessageBox.TYPE_INFO, -1)
			def errback(ret = None):
				AddPopup(_("Could not rename %s.") % (fileName), MessageBox.TYPE_ERROR, -1)

			self.ftpclient.rename(absRemoteFile, newRemoteFile).addCallback(callback).addErrback(errback)
		else:
			assert(self.currlist == "local")
			absLocalFile, fileName = self.getLocalFile()
			if not fileName:
				return

			directory = self["local"].getCurrentDirectory()
			newLocalFile = os_path.join(directory, newName)

			try:
				os_rename(absLocalFile, newLocalFile)
			except OSError as ose:
				AddPopup(_("Could not rename %s.") % (fileName), MessageBox.TYPE_ERROR, -1)
			else:
				AddPopup(_("Renamed %s to %s.") % (fileName, newName), MessageBox.TYPE_INFO, -1)
Beispiel #2
0
def moveFiles(fileList):
    movedList = []
    try:
        try:
            for item in fileList:
                os_rename(item[0], item[1])
                movedList.append(item)

        except OSError as e:
            if e.errno == 18:
                print '[Directories] cannot rename across devices, trying slow move'
                import Screens.CopyFiles
                Screens.CopyFiles.moveFiles(fileList, item[0])
                print '[Directories] Moving in background...'
            else:
                raise

    except Exception as e:
        print '[Directories] Failed move:', e
        for item in movedList:
            try:
                os_rename(item[1], item[0])
            except:
                print '[Directories] Failed to undo move:', item
                raise
Beispiel #3
0
 def compose_mono(self, answer):
     system('rm -f /lib/modules/italysat/*')
     system('rm -f /usr/bin/italysatDtt.sh')
     url = self.ItalysatDtt_geturl()
     file = self.sel[1]
     file = file.strip()
     url = url + '/' + file
     cmd = 'wget -O /tmp/' + file + ' ' + url
     rc = system(cmd)
     dest = '/tmp/' + file
     mydir = getcwd()
     chdir('/')
     cmd = 'tar -xjf ' + dest
     rc = system(cmd)
     chdir(mydir)
     cmd = 'rm -f ' + dest
     rc = system(cmd)
     system('chmod 0755 /usr/bin/italysatDtt.sh')
     if answer == '3':
         os_rename('/usr/bin/italysatDtt.sh', '/usr/bin/italysatDtt2.tmp2')
         os_rename('/lib/modules/italysat/date.txt', '/lib/modules/italysat/date2.txt')
         mybox = self.session.open(MessageBox, _('First tuner drivers installed.\n You can now select drivers for second tuner'), MessageBox.TYPE_INFO)
         mybox.setTitle('Info')
     else:
         self.write_cfg()
         mybox = self.session.open(MessageBox, _('Driver Successfully Installed.\n You can now Enable your Usb tuner'), MessageBox.TYPE_INFO)
         mybox.setTitle('Info')
         self.close()
Beispiel #4
0
    def keyOk(self):
        m = self.checkKern()
        if m != 1:
            return
        self.sel = self['list'].getCurrent()
        self.newcam = self.camnames[self.sel]
        inme = open('/etc/BhCamConf', 'r')
        out = open('/etc/BhCamConf.tmp', 'w')
        for line in inme.readlines():
            if line.find('delcurrent') == 0:
                line = 'delcurrent|' + self.newcam + '\n'
            elif line.find('deldefault') == 0:
                line = 'deldefault|' + self.newcam + '\n'
            out.write(line)

        out.close()
        inme.close()
        os_rename('/etc/BhCamConf.tmp', '/etc/BhCamConf')
        out = open('/etc/CurrentBhCamName', 'w')
        out.write(self.sel)
        out.close()
        cmd = 'cp -f ' + self.newcam + ' /usr/bin/StartBhCam'
        system(cmd)
        mydata = 'STOP_CAMD,' + self.currentcam
        client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        client_socket.connect('/tmp/Blackhole.socket')
        client_socket.send(mydata)
        client_socket.close()
        mydata = 'NEW_CAMD,' + self.newcam
        client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        client_socket.connect('/tmp/Blackhole.socket')
        client_socket.send(mydata)
        client_socket.close()
        self.session.openWithCallback(self.myclose, Nab_DoStartCam, self.sel)
Beispiel #5
0
def nab_Switch_Autocam(current, new):
    camname = 'N/A'
    inme = open('/etc/BhCamConf', 'r')
    out = open('/etc/BhCamConf.tmp', 'w')
    for line in inme.readlines():
        if line.find('delcurrent') == 0:
            line = 'delcurrent|' + new + '\n'
        out.write(line)

    out.close()
    inme.close()
    os_rename('/etc/BhCamConf.tmp', '/etc/BhCamConf')
    f = open(new, 'r')
    for line in f.readlines():
        if line.find('CAMNAME=') != -1:
            line = line.strip()
            camname = line[9:-1]

    f.close()
    out = open('/etc/CurrentBhCamName', 'w')
    out.write(camname)
    out.close()
    cmd = 'cp -f ' + new + ' /usr/bin/StartBhCam'
    system(cmd)
    client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    client_socket.connect('/tmp/Blackhole.socket')
    mydata = 'STOP_CAMD,' + current
    client_socket.send(mydata)
    client_socket.close()
    client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    client_socket.connect('/tmp/Blackhole.socket')
    mydata = 'NEW_CAMD,' + new
    client_socket.send(mydata)
    client_socket.close()
    return camname
Beispiel #6
0
    def MeStart2(self):
        check = True
        if check == True:
            out = open('/usr/bin/enigma2sh.tmp', 'w')
            f = open('/usr/bin/enigma2.sh', 'r')
            for line in f.readlines():
                if line.find('italysatDtt.sh') != -1:
                    continue
                if line.find('cd /home/root') != -1:
                    out.write('/usr/bin/italysatDtt.sh\n')
                out.write(line)

            f.close()
            out.close()
            os_rename('/usr/bin/enigma2sh.tmp', '/usr/bin/enigma2.sh')
            system('chmod 0755 /usr/bin/enigma2.sh')
            message = _(
                'Driver Up, restart E2 to start DVB-T tuner.\nRestart Enigma now?'
            )
            ybox = self.session.openWithCallback(self.restEn, MessageBox,
                                                 message,
                                                 MessageBox.TYPE_YESNO)
            ybox.setTitle('Enigma2 Restart.')
        else:
            mybox = self.session.open(
                MessageBox,
                _('Sorry, No Supported USB DTT found. \nReboot and Retries Enabled'
                  ), MessageBox.TYPE_INFO)
            mybox.setTitle('Info')
            self.close()
Beispiel #7
0
def preparar_RDD(seq_len = 0):
  from elephas.utils.rdd_utils import to_simple_rdd
  from os import rename as os_rename
  for nF in range(1, 99): # 1,...,(n-1)
    fichtr = 'clicks_X_train_' + str(seq_len) + '-' + str(nF) + '_para_spark.csv'
    if os_path_isfile(s_input_path + fichtr):
      print('Leyendo ficheros train+valid ' + str(nF) + ' - numAds ' + str(seq_len) + '...')
      X_train = read_csv(s_input_path + 'clicks_X_train_' + str(seq_len) + '-' + str(nF) + '_para_spark.csv', dtype=np_float64, header = None).values
      y_train = read_csv(s_input_path + 'clicks_y_train_' + str(seq_len) + '-' + str(nF) + '_para_spark.csv', dtype=int, header = None).values
      X_valid = read_csv(s_input_path + 'clicks_X_valid_' + str(seq_len) + '-' + str(nF) + '_para_spark.csv', dtype=np_float64, header = None).values
      y_valid = read_csv(s_input_path + 'clicks_y_valid_' + str(seq_len) + '-' + str(nF) + '_para_spark.csv', dtype=int, header = None).values
      print(X_train.shape, y_train.shape, X_valid.shape, y_valid.shape)
      X_train, y_train = mi_reshape(X_train, to_categorical(y_train), seq_len)
      X_valid, y_valid = mi_reshape(X_valid, to_categorical(y_valid), seq_len)
      X_train = np_concat((X_train, X_valid), axis=0) # Incluimos validset dentro del trainset en Spark
      y_train = np_concat((y_train, y_valid), axis=0) # Incluimos validset dentro del trainset en Spark
      print(X_train.shape, y_train.shape)
      print('Creando RDD (train+valid) ' + str(nF) + ' - numAds ' + str(seq_len) + '...')
      rdd_ini = to_simple_rdd(sc, X_train, y_train)
      # Convertimos ndarray [ i.e. array(...) ] en list [ i.e. [...] ]:
      rdd_lista = rdd_ini.map(lambda i: map(lambda s: s.tolist(), i))
      # Y ahora guardamos como txt:
      rdd_lista.coalesce(numSparkWorkers, True).saveAsTextFile(s_spark_inputpath + 'clicks_train_seq' + str(seq_len) + '-' + str(nF) + '_rdd') # Forzamos a guardarlo en 4 trozos (al menos)
      print('Ok. Guardado en HDFS el RDD (train+valid) ' + str(nF) + ' - numAds ' + str(seq_len) + '.')
  os_rename(s_input_path + fichtr, s_input_path + 'ok_en_hdfs/' + 'clicks_X_train_' + str(seq_len) + '-' + str(nF) + '_para_spark.csv')
Beispiel #8
0
	def activateVpn(self):
		
		myline = 'AUTOSTART="all"'
		mymess = _("OpenVpn Enabled. Autostart activated.")
		if self.my_vpn_active == True:
			myline = 'AUTOSTART="none"'
			mymess = _("OpenVpn disabled.")
			
		if fileExists("/usr/bin/openvpn_script.sh"):
			inme = open("/usr/bin/openvpn_script.sh",'r')
			out = open("/usr/bin/openvpn_script.tmp",'w')
			for line in inme.readlines():
				if line.find('AUTOSTART="') != -1:
					line = myline + '\n'
				out.write(line)
			out.close()
			inme.close()
			
		if fileExists("/usr/bin/openvpn_script.tmp"):
			os_rename("/usr/bin/openvpn_script.tmp", "/usr/bin/openvpn_script.sh")
			system("chmod 0755 /usr/bin/openvpn_script.sh")
		
		mybox = self.session.open(MessageBox, mymess, MessageBox.TYPE_INFO)
		mybox.setTitle("Info")
		
		self.updateVpn()
Beispiel #9
0
	def renameCallback(self, newName=None):
		if not newName:
			return

		if self.currlist == "remote":
			absRemoteFile, fileName, fileSize = self.getRemoteFile()
			if not fileName:
				return

			directory = self["remote"].getCurrentDirectory()
			sep = '/' if directory != '/' else ''
			newRemoteFile = directory + sep + newName

			def callback(ret=None):
				AddPopup(_("Renamed %s to %s.") % (fileName, newName), MessageBox.TYPE_INFO, -1)

			def errback(ret=None):
				AddPopup(_("Could not rename %s.") % (fileName), MessageBox.TYPE_ERROR, -1)

			self.ftpclient.rename(absRemoteFile, newRemoteFile).addCallback(callback).addErrback(errback)
		else:
			assert (self.currlist == "local")
			absLocalFile, fileName = self.getLocalFile()
			if not fileName:
				return

			directory = self["local"].getCurrentDirectory()
			newLocalFile = os_path.join(directory, newName)

			try:
				os_rename(absLocalFile, newLocalFile)
			except OSError as ose:
				AddPopup(_("Could not rename %s.") % (fileName), MessageBox.TYPE_ERROR, -1)
			else:
				AddPopup(_("Renamed %s to %s.") % (fileName, newName), MessageBox.TYPE_INFO, -1)
Beispiel #10
0
    def activateVpn(self):

        myline = 'AUTOSTART="all"'
        mymess = _("OpenVpn Enabled. Autostart activated.")
        if self.my_vpn_active == True:
            myline = 'AUTOSTART="none"'
            mymess = _("OpenVpn disabled.")

        if fileExists("/usr/bin/openvpn_script.sh"):
            inme = open("/usr/bin/openvpn_script.sh", 'r')
            out = open("/usr/bin/openvpn_script.tmp", 'w')
            for line in inme.readlines():
                if line.find('AUTOSTART="') != -1:
                    line = myline + '\n'
                out.write(line)
            out.close()
            inme.close()

        if fileExists("/usr/bin/openvpn_script.tmp"):
            os_rename("/usr/bin/openvpn_script.tmp",
                      "/usr/bin/openvpn_script.sh")
            system("chmod 0755 /usr/bin/openvpn_script.sh")

        mybox = self.session.open(MessageBox, mymess, MessageBox.TYPE_INFO)
        mybox.setTitle("Info")

        self.updateVpn()
Beispiel #11
0
def rename_file(file_path, new_file_path):
    from sys import exc_info as sys_excinfo
    ## We are expecting that the path will exist, since we are
    ## trying to rename it to something else, if does not exist
    ## we must raise an error
    if not os_path.exists(file_path):
        try:
            raise OSError(13, 'File does not exist', file_path)
        except OSError as e:
            print e
        return False
    ## If the new filename to which we want to rename exists, we stop
    elif os_path.exists(new_file_path):
        try:
            raise OSError(99, 'File already exists, cannot create',
                          new_file_path)
        except OSError as e:
            print e
        return False
    ## If we do not get caught be either scenario above, we need to try
    ## to rename the file, using try/except method
    else:
        try:
            os_rename(file_path, new_file_path)
        except OSError as e:
            print '%s%s %s' % (e, ', cannot rename', file_path)
            return False
    return True
Beispiel #12
0
    def keyOk(self):
        m = self.checkKern()
        if m != 1:
            return
        self.sel = self['list'].getCurrent()
        self.newcam = self.camnames[self.sel]
        inme = open('/etc/BhCamConf', 'r')
        out = open('/etc/BhCamConf.tmp', 'w')
        for line in inme.readlines():
            if line.find('delcurrent') == 0:
                line = 'delcurrent|' + self.newcam + '\n'
            elif line.find('deldefault') == 0:
                line = 'deldefault|' + self.newcam + '\n'
            out.write(line)

        out.close()
        inme.close()
        os_rename('/etc/BhCamConf.tmp', '/etc/BhCamConf')
        out = open('/etc/CurrentBhCamName', 'w')
        out.write(self.sel)
        out.close()
        cmd = 'cp -f ' + self.newcam + ' /usr/bin/StartBhCam'
        system(cmd)
        mydata = 'STOP_CAMD,' + self.currentcam
        client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        client_socket.connect('/tmp/Blackhole.socket')
        client_socket.send(mydata)
        client_socket.close()
        mydata = 'NEW_CAMD,' + self.newcam
        client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        client_socket.connect('/tmp/Blackhole.socket')
        client_socket.send(mydata)
        client_socket.close()
        self.session.openWithCallback(self.myclose, Nab_DoStartCam, self.sel)
Beispiel #13
0
	def keyOk(self):
		
		self.sel = self["list"].getCurrent()
		self.newcam = self.camnames[self.sel]
		
		inme = open("/etc/BhCamConf",'r')
		out = open("/etc/BhCamConf.tmp",'w')
		for line in inme.readlines():
			if line.find("delcurrent") == 0:
				line = "delcurrent|" + self.newcam + "\n"
			elif line.find("deldefault") == 0:
				line = "deldefault|" + self.newcam + "\n"	
			out.write(line)
		out.close()
		inme.close()
		os_rename("/etc/BhCamConf.tmp", "/etc/BhCamConf")

		out = open("/etc/CurrentBhCamName", "w")
		out.write(self.sel)
		out.close()
		cmd = "cp -f " + self.newcam + " /usr/bin/StartBhCam"
		system (cmd)
		
		mydata = "STOP_CAMD," + self.currentcam
		client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
		client_socket.connect("/tmp/Blackhole.socket")
		client_socket.send(mydata)
            	client_socket.close()
		mydata = "NEW_CAMD," + self.newcam
		client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
		client_socket.connect("/tmp/Blackhole.socket")
		client_socket.send(mydata)
            	client_socket.close()
		
		self.session.openWithCallback(self.myclose, Nab_DoStartCam, self.sel)
def rename_file(file_path,new_file_path):
    from sys import exc_info as sys_excinfo
    ## We are expecting that the path will exist, since we are
    ## trying to rename it to something else, if does not exist
    ## we must raise an error
    if not os_path.exists(file_path):
        try:
            raise OSError(13,'File does not exist',file_path)
        except OSError as e:
            print e
        return False
    ## If the new filename to which we want to rename exists, we stop
    elif os_path.exists(new_file_path):
        try:
            raise OSError(99,'File already exists, cannot create',new_file_path)
        except OSError as e:
            print e
        return False
    ## If we do not get caught be either scenario above, we need to try
    ## to rename the file, using try/except method
    else:
        try:
            os_rename(file_path,new_file_path)
        except OSError as e:
            print '%s%s %s' % (e,', cannot rename', file_path)
            return False
    return True
Beispiel #15
0
    def getIconPathFromAAueue(self, item):
        printDBG("getIconPathFromAAueue item[%s]" % item)
        if item.startswith('file://'): return item[7:]

        hashAlg = MD5()
        name = hashAlg(item)
        filename = hexlify(name) + '.jpg'

        self.lockAA.acquire()
        file_path = self.queueAA.get(filename, '')
        if file_path != '':
            try:
                if os_path.normcase(self.currDownloadDir +
                                    '/') != os_path.normcase(file_path + '/'):
                    file_path = os_path.normcase(file_path + '/' + filename)
                    os_rename(
                        file_path,
                        os_path.normcase(self.currDownloadDir + '/' +
                                         filename))
                    self.queueAA[filename] = os_path.normcase(
                        self.currDownloadDir + '/')
                    file_path = os_path.normcase(self.currDownloadDir + '/' +
                                                 filename)
                else:
                    file_path = os_path.normcase(file_path + '/' + filename)
            except Exception:
                printExc()
        self.lockAA.release()

        printDBG("getIconPathFromAAueue A file_path[%s]" % file_path)
        return file_path
Beispiel #16
0
def nab_Switch_Autocam(current, new):
    camname = 'N/A'
    inme = open('/etc/BhCamConf', 'r')
    out = open('/etc/BhCamConf.tmp', 'w')
    for line in inme.readlines():
        if line.find('delcurrent') == 0:
            line = 'delcurrent|' + new + '\n'
        out.write(line)

    out.close()
    inme.close()
    os_rename('/etc/BhCamConf.tmp', '/etc/BhCamConf')
    f = open(new, 'r')
    for line in f.readlines():
        if line.find('CAMNAME=') != -1:
            line = line.strip()
            camname = line[9:-1]

    f.close()
    out = open('/etc/CurrentBhCamName', 'w')
    out.write(camname)
    out.close()
    cmd = 'cp -f ' + new + ' /usr/bin/StartBhCam'
    system(cmd)
    client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    client_socket.connect('/tmp/Blackhole.socket')
    mydata = 'STOP_CAMD,' + current
    client_socket.send(mydata)
    client_socket.close()
    client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    client_socket.connect('/tmp/Blackhole.socket')
    mydata = 'NEW_CAMD,' + new
    client_socket.send(mydata)
    client_socket.close()
    return camname
Beispiel #17
0
def doMSA(finallistfile, outdir):
    outfile = os_path.join(outdir, "sequences.score_ascii")
    outfile_html = os_path.join(outdir, "sequences.score_ascii.score_html")
    outfile_aln = os_path.join(outdir, "sequences.score_ascii.fasta_aln")
    align_html = os_path.join(outdir, "sequences_score.html")
    align_fasta = os_path.join(outdir, "sequences_aln.fasta")
    treefile = os_path.join(outdir, "sequences.dnd")
    args = (
        "t_coffee -in {0} -mode quickaln -output=score_ascii,fasta_aln,score_html -outfile "
        .format(finallistfile) + outfile + " -newtree " + treefile)
    os_system(args)
    if os_path.exists(outfile_html):
        os_rename(outfile_html, align_html)
    if os_path.exists(outfile_aln):
        os_rename(outfile_aln, align_fasta)

    f = open(outfile, "r")

    cons = {}
    for line in f:
        if "   :  " in line:
            splitdata = line.split()
            upid = splitdata[0]
            if len(upid.split('|')) > 1:
                upid = upid.split('|')[1]
            elif len(upid.split('_')) > 1:
                upid = upid.split('_')[0]
            score = splitdata[2]
            cons[upid] = score

    return cons
Beispiel #18
0
 def compose_mono(self, answer):
     system('rm -f /lib/modules/italysat/*')
     system('rm -f /usr/bin/italysatDtt.sh')
     url = self.ItalysatDtt_geturl()
     file = self.sel[1]
     file = file.strip()
     url = url + '/' + file
     cmd = 'wget -O /tmp/' + file + ' ' + url
     rc = system(cmd)
     dest = '/tmp/' + file
     mydir = getcwd()
     chdir('/')
     cmd = 'tar -xjf ' + dest
     rc = system(cmd)
     chdir(mydir)
     cmd = 'rm -f ' + dest
     rc = system(cmd)
     system('chmod 0755 /usr/bin/italysatDtt.sh')
     if answer == '3':
         os_rename('/usr/bin/italysatDtt.sh', '/usr/bin/italysatDtt2.tmp2')
         os_rename('/lib/modules/italysat/date.txt',
                   '/lib/modules/italysat/date2.txt')
         mybox = self.session.open(
             MessageBox,
             _('First tuner drivers installed.\n You can now select drivers for second tuner'
               ), MessageBox.TYPE_INFO)
         mybox.setTitle('Info')
     else:
         self.write_cfg()
         mybox = self.session.open(
             MessageBox,
             _('Driver Successfully Installed.\n You can now Enable your Usb tuner'
               ), MessageBox.TYPE_INFO)
         mybox.setTitle('Info')
         self.close()
Beispiel #19
0
    def readXml(self):
        # Abort if no config found
        if not os_path.exists(XML_CONFIG):
            print("[AutoTimer] No configuration file present")
            return

        # Parse if mtime differs from whats saved
        mtime = os_path.getmtime(XML_CONFIG)
        if mtime == self.configMtime:
            print("[AutoTimer] No changes in configuration, won't parse")
            return

        # Save current mtime
        self.configMtime = mtime

        # Parse Config
        try:
            configuration = cet_parse(XML_CONFIG).getroot()
        except:
            try:
                if os_path.exists(XML_CONFIG + "_old"):
                    os_rename(XML_CONFIG + "_old", XML_CONFIG + "_old(1)")
                os_rename(XML_CONFIG, XML_CONFIG + "_old")
                print(
                    "[AutoTimer] autotimer.xml is corrupt rename file to /etc/enigma2/autotimer.xml_old"
                )
            except:
                pass
            if Standby.inStandby is None:
                AddPopup(_(
                    "The autotimer file (/etc/enigma2/autotimer.xml) is corrupt. A new and empty config was created. A backup of the config can be found here (/etc/enigma2/autotimer.xml_old) "
                ),
                         type=MessageBox.TYPE_ERROR,
                         timeout=0,
                         id="AutoTimerLoadFailed")

            self.timers = []
            self.defaultTimer = preferredAutoTimerComponent(
                0,  # Id
                "",  # Name
                "",  # Match
                True  # Enabled
            )

            try:
                self.writeXml()
                configuration = cet_parse(XML_CONFIG).getroot()
            except:
                print(
                    "[AutoTimer] fatal error, the autotimer.xml cannot create")
                return

        # Empty out timers and reset Ids
        del self.timers[:]
        self.defaultTimer.clear(-1, True)

        parseConfig(configuration, self.timers, configuration.get("version"),
                    0, self.defaultTimer)
        self.uniqueTimerId = len(self.timers)
Beispiel #20
0
	def _moveBackupList(self):
		try:
			fname = "%s.old" %(self._backupFile,)
			if fileExists(fname):
				os_remove(fname)
			os_rename(self._backupFile, "%s.old" %(self._backupFile,))
		except Exception as e:
			self._onRestoreRenameFailed(e)
def rename(source_path, destination_path, force=False):
    if lexists(destination_path) and force:
        rm_rf(destination_path)
    if lexists(source_path):
        log.trace("renaming %s => %s", source_path, destination_path)
        os_rename(source_path, destination_path)
    else:
        log.trace("cannot rename; source path does not exist '%s'", source_path)
Beispiel #22
0
def rename(source_path, destination_path, force=False):
    if lexists(destination_path) and force:
        rm_rf(destination_path)
    if lexists(source_path):
        log.trace("renaming %s => %s", source_path, destination_path)
        os_rename(source_path, destination_path)
    else:
        log.trace("cannot rename; source path does not exist '%s'", source_path)
Beispiel #23
0
	def _moveBackupList(self):
		try:
			fname = "%s.old" %(self._backupFile,)
			if fileExists(fname):
				os_remove(fname)
			os_rename(self._backupFile, "%s.old" %(self._backupFile,))
		except Exception as e:
			self._onRestoreRenameFailed(e)
Beispiel #24
0
 def procesS(self):
     cur = self.mylist[self.count]
     self['lab1'].setText(cur)
     if cur == 'Libraries':
         ret = system('mkdir ' + self.mytmppath + '/usr/lib')
         ret = system('cp -fd /usr/lib/* ' + self.mytmppath + '/usr/lib')
     elif cur == 'Binaries':
         ret = system('cp -fdr /usr/bin ' + self.mytmppath + '/usr')
     elif cur == 'Cams':
         ret = system('cp -rf /usr/camscript ' + self.mytmppath + '/usr')
         ret = system('cp -rf /usr/keys ' + self.mytmppath + '/usr')
         ret = system('cp -rf /usr/scce ' + self.mytmppath + '/usr')
         ret = system('cp -rf /usr/scam ' + self.mytmppath + '/usr')
     elif cur == 'Scripts':
         ret = system('cp -rf /usr/script ' + self.mytmppath + '/usr')
     elif cur == 'Bootlogos':
         ret = system('mkdir ' + self.mytmppath + '/usr/share')
         ret = system('cp -f /usr/share/*.mvi ' + self.mytmppath + '/usr/share')
     elif cur == 'Uninstall files':
         ret = system('cp -rf /usr/uninstall ' + self.mytmppath + '/usr')
     elif cur == 'General Settings':
         ret = system('mkdir ' + self.mytmppath + '/etc/rc3.d')
         ret = system('cp -fd /etc/rc3.d/* ' + self.mytmppath + '/etc/rc3.d/')
         ret = system('mkdir ' + self.mytmppath + '/etc/network')
         ret = system('cp -f /etc/* ' + self.mytmppath + '/etc')
         ret = system('cp -f /etc/network/interfaces ' + self.mytmppath + '/etc/network')
     elif cur == 'Cron':
         ret = system('cp -rf /etc/bhcron ' + self.mytmppath + '/etc')
     elif cur == 'Settings Channels Bouquets':
         ret = system('mkdir ' + self.mytmppath + '/usr/share/enigma2')
         ret = system('cp -rf /etc/enigma2 ' + self.mytmppath + '/etc')
         ret = system('cp -rf /usr/share/dict ' + self.mytmppath + '/usr/share')
         ret = system('cp -f /usr/share/enigma2/keymap.xml ' + self.mytmppath + '/usr/share/enigma2/')
     elif cur == 'Openvpn':
         ret = system('cp -rf /etc/openvpn ' + self.mytmppath + '/etc')
     elif cur == 'Satellites Terrestrial':
         ret = system('cp -rf /etc/tuxbox ' + self.mytmppath + '/etc')
     elif cur == 'Plugins':
         ret = system('mkdir ' + self.mytmppath + '/usr/lib/enigma2')
         ret = system('mkdir ' + self.mytmppath + '/usr/lib/enigma2/python')
         ret = system('mkdir ' + self.mytmppath + '/usr/lib/enigma2/python/Plugins')
         ret = system('cp -rf /usr/lib/enigma2/python/Plugins/Extensions ' + self.mytmppath + '/usr/lib/enigma2/python/Plugins')
         ret = system('cp -rf /usr/lib/enigma2/python/Plugins/SystemPlugins ' + self.mytmppath + '/usr/lib/enigma2/python/Plugins')
         self['lab1'].setText('Plugins')
     if cur != 'END':
         self.count += 1
         self.activityTimer.start(100)
     else:
         mydir = getcwd()
         chdir(self.mytmppath)
         cmd = 'tar -cf BhPersonalBackup.tar etc usr'
         rc = system(cmd)
         os_rename('BhPersonalBackup.tar', '../BhPersonalBackup.bh7')
         chdir(mydir)
         self.session.open(MessageBox, _('Backup complete !'), MessageBox.TYPE_INFO)
         self.close()
Beispiel #25
0
 def moveFullFileName(self, newPath):
     bRet = False
     msg = ''
     try:
         os_rename(self.filePath, newPath)
         self.filePath = newPath
         bRet = True
     except Exception, e:
         printExc()
         msg = str(e)
Beispiel #26
0
	def moveMovieFiles(self, fr, to):
		try:
			os_rename(fr + ".ts", to + ".ts")
		except OSError:
			print "Moving in background"
			global_background_mover.enqueue(self.exitDialog, self.session, fr, to)
		else:
			print "Moving in foreground"
			for suff in (".ts.meta", ".ts.cuts", ".ts.ap", ".ts.sc", ".eit"):
				if os_path.exists(fr + suff):
					os_rename(fr + suff, to + suff)
			self.exitDialog()
Beispiel #27
0
	def moveMovieFiles(self, fr, to):
		try:
			os_rename(fr + ".ts", to + ".ts")
		except OSError:
			print("Moving in background")
			global_background_mover.enqueue(self.exitDialog, self.session, fr, to)
		else:
			print("Moving in foreground")
			for suff in (".ts.meta", ".ts.cuts", ".ts.ap", ".ts.sc", ".eit"):
				if os_path.exists(fr + suff):
					os_rename(fr + suff, to + suff)
			self.exitDialog()
Beispiel #28
0
	def deltocam(self):
		mysel = self["list"].getCurrent()
		if mysel:
			mysel = mysel[1]
			out = open("/etc/BhCamConf.tmp", "w")
			f = open("/etc/BhCamConf",'r')
			for line in f.readlines():
				parts = line.strip().split("|")
				if parts[0] != mysel:
					out.write(line)
			f.close()
			out.close()
			os_rename("/etc/BhCamConf.tmp", "/etc/BhCamConf")
			self.updateList()
Beispiel #29
0
    def deltocam(self):
        mysel = self['list'].getCurrent()
        if mysel:
            mysel = mysel[1]
            out = open('/etc/BhCamConf.tmp', 'w')
            f = open('/etc/BhCamConf', 'r')
            for line in f.readlines():
                parts = line.strip().split('|')
                if parts[0] != mysel:
                    out.write(line)

            f.close()
            out.close()
            os_rename('/etc/BhCamConf.tmp', '/etc/BhCamConf')
            self.updateList()
Beispiel #30
0
    def deltocam(self):
        mysel = self['list'].getCurrent()
        if mysel:
            mysel = mysel[1]
            out = open('/etc/BhCamConf.tmp', 'w')
            f = open('/etc/BhCamConf', 'r')
            for line in f.readlines():
                parts = line.strip().split('|')
                if parts[0] != mysel:
                    out.write(line)

            f.close()
            out.close()
            os_rename('/etc/BhCamConf.tmp', '/etc/BhCamConf')
            self.updateList()
Beispiel #31
0
	def callbackRenameItem(self, answer):
		if answer is not None:
			if self.type == "file":
				path = self["filelist"].getCurrentDirectory()
				source = path + self.item
				dest = path + answer
			elif self.type == "directory":
				source = self.item
				dest = answer
				
			try:
				os_rename(source, dest)
			except:
				msg = self.session.open(MessageBox,_("Rename: %s \nfailed!" % answer), MessageBox.TYPE_ERROR, windowTitle=_("Dream-Explorer"))
			self["filelist"].refresh()
Beispiel #32
0
    def MeStop(self):
        if self.my_dtt_active == True:
            out = open('/usr/bin/enigma2sh.tmp', 'w')
            f = open('/usr/bin/enigma2.sh', 'r')
            for line in f.readlines():
                if line.find('italysatDtt.sh') != -1:
                    continue
                out.write(line)

            f.close()
            out.close()
            os_rename('/usr/bin/enigma2sh.tmp', '/usr/bin/enigma2.sh')
            system('chmod 0755 /usr/bin/enigma2.sh')
            message = _('Tuner deactivation need a reboot to take effects.\nReboot your stb now?')
            ybox = self.session.openWithCallback(self.restBo, MessageBox, message, MessageBox.TYPE_YESNO)
            ybox.setTitle('Reboot.')
Beispiel #33
0
	def savePoints(self):
		f = open("/etc/fstab",'r')
		out = open("/etc/fstab.tmp", "w")
		for line in f.readlines():
			if line.find("UUID") != -1 or len(line) < 6:
				continue
			out.write(line)
		for x in self["config"].list:
			if x[1].value != "Not mapped":
				line = "UUID=%s    %s    auto   defaults    0  0\n" % (x[2], x[1].value)
				out.write(line)

		out.write("\n")
		f.close()
		out.close()
		os_rename("/etc/fstab.tmp", "/etc/fstab")
		message = _("Devices changes need a system restart to take effects.\nRestart your Box now?")
		self.session.openWithCallback(self.restBo, MessageBox, message, MessageBox.TYPE_YESNO)
Beispiel #34
0
	def savePoints(self):
		f = open("/etc/fstab",'r')
		out = open("/etc/fstab.tmp", "w")
		for line in f.readlines():
			if line.find("UUID") != -1 or len(line) < 6:
				continue
			out.write(line)
		for x in self["config"].list:
			if x[1].value != "No mapeado":
				line = "UUID=%s    %s    auto   defaults    0  0\n" % (x[2], x[1].value)
				out.write(line)

		out.write("\n")
		f.close()
		out.close()
		os_rename("/etc/fstab.tmp", "/etc/fstab")
		message = "Cambios realizados al dispositivo, necesita reiniciar para tener efecto\nReiniciar su Receptor ahora?"
		self.session.openWithCallback(self.restBo, MessageBox, message, MessageBox.TYPE_YESNO)
Beispiel #35
0
def create_and_train_one(models_dirname, model_type, model_version,
                         model_index):
    '''
    Args:
        models_dirname is probably DNNS/
    '''
    print(
        'create_and_train_one: models_dirname={}, model_type={}, model_version={}, model_index={}'
        .format(models_dirname, model_type, model_version, model_index))
    model_dirpath = create_one_model_keras(models_dirname, model_type,
                                           model_version, model_index)

    new_model_folder_name = model_dirpath.replace('_created', '_training')
    os_rename(model_dirpath, new_model_folder_name)
    train_one_model_keras(new_model_folder_name)

    os_rename(new_model_folder_name,
              new_model_folder_name.replace('_training', '_trained'))
Beispiel #36
0
	def savePoints(self):
		f = open("/etc/fstab",'r')
		out = open("/etc/fstab.tmp", "w")
		for line in f.readlines():
			if line.find("UUID") != -1 or len(line) < 6:
				continue
			out.write(line)
		for x in self["config"].list:
			if x[1].value != "Not mapped":
				line = "UUID=%s    %s    auto   defaults    0  0\n" % (x[2], x[1].value)
				out.write(line)

		out.write("\n")
		f.close()
		out.close()
		os_rename("/etc/fstab.tmp", "/etc/fstab")
		message = "Devices changes need a system restart to take effects.\nRestart your Box now?"
		self.session.openWithCallback(self.restBo, MessageBox, message, MessageBox.TYPE_YESNO)
Beispiel #37
0
def rename(source_path, destination_path, force=False):
    if lexists(destination_path) and force:
        rm_rf(destination_path)
    if lexists(source_path):
        log.trace("renaming %s => %s", source_path, destination_path)
        try:
            os_rename(source_path, destination_path)
        except EnvironmentError as e:
            if e.errno in (EINVAL, EXDEV):
                # see https://github.com/conda/conda/issues/6711
                log.trace(
                    "Could not rename do to errno [%s]. Falling back to copy/remove.",
                    e.errno)
                _copy_then_remove(source_path, destination_path)
            else:
                raise
    else:
        log.trace("cannot rename; source path does not exist '%s'",
                  source_path)
Beispiel #38
0
def rename(regex: Pattern[AnyStr], to: str, path: str) -> bool:
    """Dosya veya dizini yeniden adlandırma

    Arguments:
        regex {Pattern[AnyStr]} -- Aranan regex
        to {str} -- Yeni isim
        path {str} -- Yol

    Returns:
        bool -- Adlandırma yapıldıysa true
    """
    new_path = common.rename_string(regex, to, path)
    if path != new_path:
        os_rename(path, new_path)

        logger.info(f"{path} -> {new_path} taşındı")
        return True

    return False
Beispiel #39
0
    def savePoints(self):
        f = open('/etc/fstab', 'r')
        out = open('/etc/fstab.tmp', 'w')
        for line in f.readlines():
            if line.find('UUID') != -1 or len(line) < 6:
                continue
            out.write(line)

        for x in self['config'].list:
            if x[1].value != 'Not mapped':
                line = 'UUID=%s    %s    auto   defaults    0  0\n' % (x[2], x[1].value)
                out.write(line)

        out.write('\n')
        f.close()
        out.close()
        os_rename('/etc/fstab.tmp', '/etc/fstab')
        message = _('Devices changes need a system restart to take effects.\nRestart your Box now?')
        self.session.openWithCallback(self.restBo, MessageBox, message, MessageBox.TYPE_YESNO)
Beispiel #40
0
    def savePoints(self):
        f = open("/etc/fstab", 'r')
        out = open("/etc/fstab.tmp", "w")
        for line in f.readlines():
            if line.find("UUID") != -1 or len(line) < 6:
                continue
            out.write(line)
        for x in self["config"].list:
            if x[1].value != "No mapeado":
                line = "UUID=%s    %s    auto   defaults    0  0\n" % (
                    x[2], x[1].value)
                out.write(line)

        out.write("\n")
        f.close()
        out.close()
        os_rename("/etc/fstab.tmp", "/etc/fstab")
        message = "Cambios realizados al dispositivo, necesita reiniciar para tener efecto\nReiniciar su Receptor ahora?"
        self.session.openWithCallback(self.restBo, MessageBox, message,
                                      MessageBox.TYPE_YESNO)
Beispiel #41
0
    def MeStop(self):
        if self.my_dtt_active == True:
            out = open('/usr/bin/enigma2sh.tmp', 'w')
            f = open('/usr/bin/enigma2.sh', 'r')
            for line in f.readlines():
                if line.find('italysatDtt.sh') != -1:
                    continue
                out.write(line)

            f.close()
            out.close()
            os_rename('/usr/bin/enigma2sh.tmp', '/usr/bin/enigma2.sh')
            system('chmod 0755 /usr/bin/enigma2.sh')
            message = _(
                'Tuner deactivation need a reboot to take effects.\nReboot your stb now?'
            )
            ybox = self.session.openWithCallback(self.restBo, MessageBox,
                                                 message,
                                                 MessageBox.TYPE_YESNO)
            ybox.setTitle('Reboot.')
Beispiel #42
0
def rename(source_path, destination_path, force=False):
    if lexists(destination_path) and force:
        rm_rf(destination_path)
    if lexists(source_path):
        log.trace("renaming %s => %s", source_path, destination_path)
        try:
            os_rename(source_path, destination_path)
        except EnvironmentError as e:
            if e.errno in (EINVAL, EXDEV):
                # https://github.com/conda/conda/issues/6811
                # https://github.com/conda/conda/issues/6711
                log.trace("Could not rename %s => %s due to errno [%s]. Falling back"
                          " to copy/unlink", source_path, destination_path, e.errno)
                # https://github.com/moby/moby/issues/25409#issuecomment-238537855
                # shutil.move() falls back to copy+unlink
                move(source_path, destination_path)
            else:
                raise
    else:
        log.trace("cannot rename; source path does not exist '%s'", source_path)
Beispiel #43
0
def rename(source_path, destination_path, force=False):
    if lexists(destination_path) and force:
        rm_rf(destination_path)
    if lexists(source_path):
        log.trace("renaming %s => %s", source_path, destination_path)
        try:
            os_rename(source_path, destination_path)
        except EnvironmentError as e:
            if e.errno in (EINVAL, EXDEV):
                # https://github.com/conda/conda/issues/6811
                # https://github.com/conda/conda/issues/6711
                log.trace("Could not rename %s => %s due to errno [%s]. Falling back"
                          " to copy/unlink", source_path, destination_path, e.errno)
                # https://github.com/moby/moby/issues/25409#issuecomment-238537855
                # shutil.move() falls back to copy+unlink
                move(source_path, destination_path)
            else:
                raise
    else:
        log.trace("cannot rename; source path does not exist '%s'", source_path)
    def render_POST(self, req):
        data = req.args['file'][0]
        print("[filename req.args]", req.args['filename'][0])
        filename = mbasename(req.args['filename'][0])
        print("[filename]", filename)
        if not filename.endswith(".ipk"):
            return self.res % (_("wrong filetype!"), _("Close"), _("Add"))

        if not data:
            req.setResponseCode(http.OK)
            return self.res % (_("filesize was 0, not uploaded"), _("Close"),
                               _("Add"))

        fd, fn = mkstemp(dir="/tmp/")
        cnt = os_write(fd, data)
        os_close(fd)
        os_chmod(fn, 0o755)

        if cnt <= 0:  # well, actually we should check against len(data) but lets assume we fail big time or not at all
            try:
                os_unlink(fn)
            except OSError as oe:
                pass
            req.setResponseCode(http.OK)
            return self.res % (_("error writing to disk, not uploaded"),
                               _("Close"), _("Add"))

        else:
            file = "/tmp/" + filename
            os_rename(fn, (file))
            if file is not None:
                out = os_popen("opkg install %s" % file)
                debug = ""
                for line in out:
                    debug += line
            else:
                return self.res % (_("error writing to disk, not uploaded"),
                                   _("Close"), _("Add"))

            req.setResponseCode(http.OK)
            return self.res % ((debug), _("Close"), _("Add"))
Beispiel #45
0
	def keyOk(self):
		self.sel = self['list'].getCurrent()
		self.newcam = self.camnames[self.sel]
		inme = open('/etc/LdCamConf', 'r')
		out = open('/etc/LdCamConf.tmp', 'w')
		for line in inme.readlines():
			if line.find('deldefault') == 0:
				line = 'deldefault|' + self.newcam + '\n'
			out.write(line)

		out.close()
		inme.close()
		os_rename('/etc/LdCamConf.tmp', '/etc/LdCamConf')
		out = open('/etc/CurrentLdCamName', 'w')
		out.write(self.sel)
		out.close()
		cmd = 'cp -f ' + self.newcam + ' /usr/bin/StartLdCam'
		system(cmd)
		cmd = 'STOP_CAMD,' + self.defaultcam
		self.sendtoLd_sock(cmd)
		self.session.openWithCallback(self.keyOk2, startstopCam, self.defCamname, _('Stopping'))
Beispiel #46
0
def nab_Switch_Autocam(current, new):
	camname = "N/A"
	inme = open("/etc/BhCamConf",'r')
	out = open("/etc/BhCamConf.tmp",'w')
	for line in inme.readlines():
		if line.find("delcurrent") == 0:
			line = "delcurrent|" + new + "\n"	
		out.write(line)
	out.close()
	inme.close()
	os_rename("/etc/BhCamConf.tmp", "/etc/BhCamConf")

	f = open(new,'r')
	for line in f.readlines():
		if line.find('CAMNAME=') != -1:
			line = line.strip()
			camname = line[9:-1]		
	f.close()

	out = open("/etc/CurrentBhCamName", "w")
	out.write(camname)
	out.close()
	cmd = "cp -f " + new + " /usr/bin/StartBhCam"
	system (cmd)
	
	client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
	client_socket.connect("/tmp/Blackhole.socket")
	mydata = "STOP_CAMD," + current
	client_socket.send(mydata)
	client_socket.close()
	client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
	client_socket.connect("/tmp/Blackhole.socket")
	mydata = "NEW_CAMD," + new
	client_socket.send(mydata)
        client_socket.close()
	
	return camname
	
	
Beispiel #47
0
 def getIconPathFromAAueue(self, item):
     printDBG("getIconPathFromAAueue item[%s]" % item)
     hashAlg = MD5()
     name = hashAlg(item)
     filename = hexlify(name) + '.jpg'
     
     self.lockAA.acquire()
     file_path = self.queueAA.get(filename, '')
     if file_path != '':
         try:
             if os_path.normcase(self.currDownloadDir+'/') != os_path.normcase(file_path+'/'):
                 file_path = os_path.normcase(file_path + '/' + filename)
                 os_rename(file_path, os_path.normcase(self.currDownloadDir + '/' + filename))
                 self.queueAA[filename] = os_path.normcase(self.currDownloadDir + '/' )
                 file_path = os_path.normcase(self.currDownloadDir + '/' + filename)
             else:
                 file_path = os_path.normcase(file_path + '/' + filename)
         except:
             printExc()
     self.lockAA.release()
     
     printDBG("getIconPathFromAAueue A file_path[%s]" % file_path)
     return file_path
Beispiel #48
0
def moveFiles(fileList):
    movedList = []
    try:
        try:
            for item in fileList:
                os_rename(item[0], item[1])
                movedList.append(item)
        except OSError, e:
            if e.errno == 18:
                print "[Directories] cannot rename across devices, trying slow move"
                import Screens.CopyFiles
                Screens.CopyFiles.moveFiles(fileList, item[0])
                print "[Directories] Moving in background..."
            else:
                raise
    except Exception, e:
        print "[Directories] Failed move:", e
        for item in movedList:
            try:
                os_rename(item[1], item[0])
            except:
                print "[Directories] Failed to undo move:", item
                raise
Beispiel #49
0
    def MeStart2(self):
        check = True
        if check == True:
            out = open('/usr/bin/enigma2sh.tmp', 'w')
            f = open('/usr/bin/enigma2.sh', 'r')
            for line in f.readlines():
                if line.find('italysatDtt.sh') != -1:
                    continue
                if line.find('cd /home/root') != -1:
                    out.write('/usr/bin/italysatDtt.sh\n')
                out.write(line)

            f.close()
            out.close()
            os_rename('/usr/bin/enigma2sh.tmp', '/usr/bin/enigma2.sh')
            system('chmod 0755 /usr/bin/enigma2.sh')
            message = _('Driver Up, restart E2 to start DVB-T tuner.\nRestart Enigma now?')
            ybox = self.session.openWithCallback(self.restEn, MessageBox, message, MessageBox.TYPE_YESNO)
            ybox.setTitle('Enigma2 Restart.')
        else:
            mybox = self.session.open(MessageBox, _('Sorry, No Supported USB DTT found. \nReboot and Retries Enabled'), MessageBox.TYPE_INFO)
            mybox.setTitle('Info')
            self.close()
Beispiel #50
0
    def savePoints(self):
        f = open('/etc/fstab', 'r')
        out = open('/etc/fstab.tmp', 'w')
        for line in f.readlines():
            if line.find('UUID') != -1 or len(line) < 6:
                continue
            out.write(line)

        for x in self['config'].list:
            if x[1].value != 'Not mapped':
                line = 'UUID=%s    %s    auto   defaults    0  0\n' % (
                    x[2], x[1].value)
                out.write(line)

        out.write('\n')
        f.close()
        out.close()
        os_rename('/etc/fstab.tmp', '/etc/fstab')
        message = _(
            'Devices changes need a system restart to take effects.\nRestart your Box now?'
        )
        self.session.openWithCallback(self.restBo, MessageBox, message,
                                      MessageBox.TYPE_YESNO)
	def procesS(self):
		cur = self.mylist[self.count]
		self['label'].setText(cur)
		if cur == 'Libraries':
			ret = system('cp -fd /lib/* ' + self.mytmppath + '/lib')
			ret = system('mkdir ' + self.mytmppath + '/usr/lib')
			ret = system('cp -fd /usr/lib/* ' + self.mytmppath + '/usr/lib')
		else:
			if cur == 'Firmwares':
				ret = system('cp -rf /lib/firmware ' + self.mytmppath + '/lib')
				ret = system('mkdir ' + self.mytmppath + '/lib/modules')
				ret = system('cp -rf /lib/modules/* ' + self.mytmppath + '/lib/modules')
			else:
				if cur == 'Binaries':
					ret = system('cp -fdr /usr/bin ' + self.mytmppath + '/usr')
				else:
					if cur == 'SoftCams':
						ret = system('cp -rf /usr/emu_scripts ' + self.mytmppath + '/usr')
						ret = system('cp -rf /usr/keys ' + self.mytmppath + '/usr')
						ret = system('cp -rf /usr/scce ' + self.mytmppath + '/usr')
						ret = system('cp -rf /usr/scam ' + self.mytmppath + '/usr')
						ret = system('cp -rf /usr/tuxbox ' + self.mytmppath + '/usr')
					else:
						if cur == 'Scripts':
							ret = system('cp -rf /usr/scripts ' + self.mytmppath + '/usr')
							ret = system('cp -rf /scripts/* ' + self.mytmppath + '/scripts')
						else:
							if cur == 'Bootlogos':
								ret = system('mkdir ' + self.mytmppath + '/usr/share')
								ret = system('cp -f /usr/share/*.mvi ' + self.mytmppath + '/usr/share')
							else:
								if cur == 'Uninstall files':
									ret = system('mkdir ' + self.mytmppath + '/usr/tuxbox')
									ret = system('cp -rf /usr/uninstall ' + self.mytmppath + '/usr')
									ret = system('cp -rf /usr/tuxbox/uninstall_emu ' + self.mytmppath + '/usr/tuxbox/')
								else:
									if cur == 'General Settings':
										ret = system('mkdir ' + self.mytmppath + '/media/hdd')
										ret = system('mkdir ' + self.mytmppath + '/media/usb')
										ret = system('mkdir ' + self.mytmppath + '/media/usb2')
										ret = system('mkdir ' + self.mytmppath + '/media/usb3')
										ret = system('cp -rf /media/hdd/crossepg ' + self.mytmppath + '/media/hdd')
										ret = system('cp -rf /media/usb/crossepg ' + self.mytmppath + '/media/usb')
										ret = system('cp -rf /media/usb2/crossepg ' + self.mytmppath + '/media/usb2')
										ret = system('cp -rf /media/usb3/crossepg ' + self.mytmppath + '/media/usb3')
										ret = system('mkdir ' + self.mytmppath + '/etc/network')
										ret = system('cp -f /etc/* ' + self.mytmppath + '/etc')
										ret = system('cp -rf /etc/magic ' + self.mytmppath + '/etc')
										ret = system('cp -f /etc/network/interfaces ' + self.mytmppath + '/etc/network')
										ret = system('cp -rf /etc/MultiQuickButton ' + self.mytmppath + '/etc')
									else:
										if cur == 'Cron':
											ret = system('cp -rf /etc/cron ' + self.mytmppath + '/etc')
										else:
											if cur == 'Settings Channels Bouquets':
												ret = system('mkdir ' + self.mytmppath + '/usr/share/enigma2')
												ret = system('cp -rf /etc/enigma2 ' + self.mytmppath + '/etc')
												ret = system('cp -f /usr/share/enigma2/keymap.xml ' + self.mytmppath + '/usr/share/enigma2/')
											else:
												if cur == 'Openvpn':
													ret = system('cp -rf /etc/openvpn ' + self.mytmppath + '/etc')
												else:
													if cur == 'Satellites Terrestrial':
														ret = system('cp -rf /etc/tuxbox ' + self.mytmppath + '/etc')
													else:
														if cur == 'Plugins':
															ret = system('mkdir ' + self.mytmppath + '/usr/lib/enigma2')
															ret = system('mkdir ' + self.mytmppath + '/usr/lib/enigma2/python')
															ret = system('mkdir ' + self.mytmppath + '/usr/lib/enigma2/python/Plugins')
															ret = system('cp -rf /usr/lib/enigma2/python/Plugins/Extensions ' + self.mytmppath + '/usr/lib/enigma2/python/Plugins')
															ret = system('cp -rf /usr/lib/enigma2/python/Plugins/SystemPlugins ' + self.mytmppath + '/usr/lib/enigma2/python/Plugins')
															self['label'].setText('Plugins')
		if cur != 'END':
			self.count += 1
			self.activityTimer.start(100)
		else:
			mydir = getcwd()
			chdir(self.mytmppath)
			cmd = 'tar -cf magic_Backup.tar etc lib media usr scripts'
			rc = system(cmd)
			import datetime
			import time
			now = datetime.datetime.now()
			czas = now.strftime("%Y%m%d")
			filename = '../'+czas + '_magic_Backup.egi' 
			os_rename('magic_Backup.tar', filename)
			chdir(mydir)
			self.session.open(MessageBox, _("magic Backup complete! Please wait..."), MessageBox.TYPE_INFO, timeout=4)
			self.close()
Beispiel #52
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     self._fd.close()
     if exc_tb is None:
         # No exception, so rename
         os_rename(self._temp_filename, self._final_filename)
Beispiel #53
0
		fd,fn = mkstemp(dir = "/tmp/")
		cnt = os_write(fd, data)
		os_close(fd)
		os_chmod(fn, 0755)
		
		if cnt <= 0: # well, actually we should check against len(data) but lets assume we fail big time or not at all
			try:
				os_unlink(fn)
			except OSError, oe:
				pass
			req.setResponseCode(http.OK)
			return  self.res % (_("error writing to disk, not uploaded"),_("Close"), _("Add"))
		
		else:
			file = "/tmp/" + filename
			os_rename(fn,(file))
			if file is not None:
				out = os_popen("opkg install %s" %file)
				debug = ""
				for line in out:
					debug += line
			else:
				return  self.res % (_("error writing to disk, not uploaded"),_("Close"), _("Add"))

			req.setResponseCode(http.OK)
			return self.res % ((debug),
					_("Close"),
					 _("Add")
					)

	def render_GET(self, req):
Beispiel #54
0
    extra.log(aud.tag.track_num[0], aud.tag.title)

# Ask if user want to rename files
extra.cls()
ch = raw_input("Do you wish to rename files? >> (Y/N) ").lower()
if ch == "y":
    print """\n
    Select Pattern
    1. <Track Number> <Title> (default)
    2. <Artist> - <Title>\n
    >> """,
    ch = raw_input()
    for i in mp3files:
        aud = eyed3load(dirname + "/" + i)
        if ch == "2":
            ren_pattern = str(aud.tag.artist) + " - " + aud.tag.title
        else:
            ren_pattern = str(aud.tag.track_num[0]) + " " + aud.tag.title
        new_name = dirname + "/" + ren_pattern + ".mp3"
        os_rename(dirname + "/" + i, new_name)

extra.cls()
print """
    All Set, Exiting the program, 
    If you've faced any problem, please send log.txt file to author
    Else delete that file

    Press Any Key to Exit.......
    """,
raw_input()
        fd, fn = mkstemp(dir=uploaddir)
        cnt = os_write(fd, data)
        os_close(fd)
        os_chmod(fn, 0755)

        if cnt <= 0:  # well, actually we should check against len(data) but lets assume we fail big time or not at all
            try:
                os_unlink(fn)
            except OSError, oe:
                pass
            req.setResponseCode(http.OK)
            req.setHeader("Content-type", "text/html")
            return "error writing to disk, not uploaded"
        else:
            file = uploaddir + filename
            os_rename(fn, file)
            return """
					<?xml version="1.0" encoding="UTF-8"?>
					<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
							"http://www.w3.org/TR/html4/loose.dtd">
					<html>
					
					<head>
					<meta content="text/html; charset=UTF-8" http-equiv="content-type">
					
					<link href="/web-data/tpl/default/style.min.css" type="text/css" rel="stylesheet">
					<link rel="shortcut icon" type="image/x-icon" href="/web-data/img/favicon.ico">
					</head>
					<body onunload="javascript:opener.location.reload()" >
						<hr>
						<p align="left">
      file_content = file_content.replace(OrigTemplateName, NEW_PROJECT_NAME)

   if OrigTemplateName__lower_case in file_content:
      file_content = file_content.replace(OrigTemplateName__lower_case, NewProjectName__lower_case)

   if OrigTemplateOneLineDescription in file_content:
      file_content = file_content.replace(OrigTemplateOneLineDescription, NEW_PROJECT_ONE_LINE_DESCRIPTION)

   with open(file_path, 'w') as file_p:
      file_p.write(file_content)


# SECOND: replace File Names
for root, file_name in FileList:
   if OrigTemplateName in file_name:
      new_file_name = file_name.replace(OrigTemplateName, NEW_PROJECT_NAME)
      os_rename(path_join(root, file_name), path_join(root, new_file_name))


# THIRD: replace Dir Names
for root, dir_ in DirList:
   if dir_ == OrigTemplateName:
      os_rename(path_join(root, dir_), path_join(root, NEW_PROJECT_NAME))


# FINALLY: rename the Root folder
NewPathName = '{}/{}'.format(path_dirname(TEMPLATE_PyPROJECT_DIR_PATH), NEW_PROJECT_NAME)
os_rename(TEMPLATE_PyPROJECT_DIR_PATH, NewPathName)

print('\nFINISHED....\n')