コード例 #1
0
ファイル: GOSsettings.py プロジェクト: mickeyreg/GOS-plugins
 def opkg2test(self, decyzja): #tutaj wpadniemy jedynie po zmianie repo, czyli raz
     if decyzja is False:
         return
     #czyli zmieniamy
     if config.GOSsettings.opkg.value == "ready" or config.GOSsettings.opkg.value == "testing":
         if not fileExists("/etc/opkg/opkg-ready.conf"):
             os_symlink("/etc/opkg/ready.gos","/etc/opkg/opkg-ready.conf")
     if config.GOSsettings.opkg.value == "testing":
         if not fileExists("/etc/opkg/opkg-testing.conf"):
             os_symlink("/etc/opkg/testing.gos","/etc/opkg/opkg-testing.conf")
コード例 #2
0
ファイル: GOSsettings.py プロジェクト: tuxdell/GOS-plugins
    def keySave(self):  #openpliPC - F2 emuluje green
        myContent = "### Utworzono za pomocą konfiguratora ustawień GOS @j00zek ###\n"
        for x in self["config"].list:
            for GOSsetting in GOSsettings_list:
                if GOSsetting[0] == x[1]:
                    opcja = GOSsetting[1]
                    wartosc = x[1].getValue()
                    if GOSsetting[
                            2] == "CONFIG":  # do konfiguracji, tylko konfiguracje
                        # wymuszenie wartosci standardowych
                        if str(opcja) == "usePeriod" and str(wartosc) == 130:
                            wartosc = 0
                        elif str(opcja) == "useDelay" and str(wartosc) == 20:
                            wartosc = 0

                        if str(wartosc) not in [
                                "0", "lircd.conf"
                        ]:  # tu ewentualnie dopisac, jakie zmienne są defaultowe
                            myContent += str(opcja) + '=' + str(wartosc) + '\n'
                    elif GOSsetting[2] == "DEF":  # musimy zalatwic procedurą
                        print str(opcja)
                        #opkg
                        if str(opcja) == "opkg":
                            if wartosc != "NA":  #NA to nasz defaultowy release, po prostu not available ;)
                                self.session.openWithCallback(
                                    self.opkg2test, MessageBox,
                                    _("Are you sure, you want to switch opkg branch to UNSTABLE %s?"
                                      ) % wartosc, MessageBox.TYPE_YESNO)
                        #reportGS
                        elif str(opcja) == "ReportGS":
                            if config.GOSsettings.ReportGS.value == "off" and fileExists(
                                    "/etc/rc.d/rc5.d/S90reportGS"):
                                os_remove("/etc/rc.d/rc5.d/S90reportGS")
                            elif config.GOSsettings.ReportGS.value == "on" and not fileExists(
                                    "/etc/rc.d/rc5.d/S90reportGS"):
                                os_chmod(
                                    resolveFilename(
                                        SCOPE_PLUGINS,
                                        'Extensions/GOSmanager/components/reportGS'
                                    ), 0775)
                                os_symlink(
                                    resolveFilename(
                                        SCOPE_PLUGINS,
                                        'Extensions/GOSmanager/components/reportGS'
                                    ), "/etc/rc.d/rc5.d/S90reportGS")

            x[1].save()
        #zapis konfiguracji gos
        with open(self.MySetupFile, "w") as myconfigfile:
            myconfigfile.write(myContent)
            myconfigfile.flush()
            os_fsync(myconfigfile.fileno())
            myconfigfile.close()
        configfile.save()
        self.close()
コード例 #3
0
ファイル: GOSsettings.py プロジェクト: tuxdell/GOS-plugins
 def opkg2test(
         self,
         decyzja):  #tutaj wpadniemy jedynie po zmianie repo, czyli raz
     if decyzja is False:
         return
     #czyli zmieniamy
     if config.GOSsettings.opkg.value == "ready" or config.GOSsettings.opkg.value == "testing":
         if not fileExists("/etc/opkg/opkg-ready.conf"):
             os_symlink("/etc/opkg/ready.gos", "/etc/opkg/opkg-ready.conf")
     if config.GOSsettings.opkg.value == "testing":
         if not fileExists("/etc/opkg/opkg-testing.conf"):
             os_symlink("/etc/opkg/testing.gos",
                        "/etc/opkg/opkg-testing.conf")
コード例 #4
0
def symlink(target, source):
    """Creates a symbolic link from `source` to `target`.
    """
    # from os import symlink# path, remove
    # from matdb import msg
    if path.isfile(target) or path.islink(target):
        remove(target)
    elif path.isdir(target):
        msg.warn(
            "Cannot auto-delete directory '{}' for symlinking.".format(target))
        return

    os_symlink(source, target)
コード例 #5
0
ファイル: GOSsettings.py プロジェクト: mickeyreg/GOS-plugins
 def keySave(self): #openpliPC - F2 emuluje green
     myContent = "### Utworzono za pomocą konfiguratora ustawień GOS @j00zek ###\n"
     for x in self["config"].list:
         for GOSsetting in GOSsettings_list:
             if GOSsetting[0] == x[1]:
                 opcja = GOSsetting[1]
                 wartosc = x[1].getValue()
                 if GOSsetting[2] == "CONFIG": # do konfiguracji, tylko konfiguracje
                     # wymuszenie wartosci standardowych
                     if str(opcja) == "usePeriod" and str(wartosc) == 130: wartosc=0
                     elif str(opcja) == "useDelay" and str(wartosc) == 20: wartosc=0
                     
                     if str(wartosc) not in ["0" , "lircd.conf"]: # tu ewentualnie dopisac, jakie zmienne są defaultowe
                         myContent += str(opcja) + '=' + str(wartosc) + '\n'
                 elif GOSsetting[2] == "DEF": # musimy zalatwic procedurą
                     print str(opcja)
                     #opkg
                     if str(opcja) == "opkg":
                         if wartosc != "NA": #NA to nasz defaultowy release, po prostu not available ;)
                             self.session.openWithCallback(self.opkg2test,MessageBox,_("Are you sure, you want to switch opkg branch to UNSTABLE %s?") % wartosc, MessageBox.TYPE_YESNO)
                     #reportGS
                     elif str(opcja) == "ReportGS":
                         if config.GOSsettings.ReportGS.value == "off" and fileExists("/etc/rc.d/rc5.d/S90reportGS"):
                             os_remove("/etc/rc.d/rc5.d/S90reportGS")
                         elif config.GOSsettings.ReportGS.value == "on" and not fileExists("/etc/rc.d/rc5.d/S90reportGS"):
                             os_chmod(resolveFilename(SCOPE_PLUGINS, 'Extensions/GOSmanager/components/reportGS'), 0775)
                             os_symlink(resolveFilename(SCOPE_PLUGINS, 'Extensions/GOSmanager/components/reportGS'),"/etc/rc.d/rc5.d/S90reportGS")
                             
         x[1].save()
     #zapis konfiguracji gos
     with open (self.MySetupFile, "w") as myconfigfile:
         myconfigfile.write(myContent)
         myconfigfile.flush()
         os_fsync(myconfigfile.fileno())
         myconfigfile.close()
     configfile.save()
     self.close()
コード例 #6
0
new_def_interfaces_path = os_path.join(ifcfg_dir,new_def_interfaces)

## If the 'interfaces.static' file does not exist, we need
## to create it, since we will write new config to it
## and we will symlink it via /etc/network/interfaces
if not check_ifcfg_file_exists(static_interfaces_path):
    x = touch_file(static_interfaces_path)
    ## If we cannot successfully create 'interfaces.static' file
    ## we need to bail here
    if x == False:
        system_exit(1)
    ## Assuming we got this far, we can now write our pre-defined template
    ## to the 'interfaces.static' file
    with open(static_interfaces_path, 'wt') as f:
        f.write(template)
if check_ifcfg_file_exists(def_interfaces_path) and not check_file_islink(def_interfaces_path):
    x = rename_file(def_interfaces_path,new_def_interfaces_path)
    if not x:
        print '%s %s' % ('Failed with rename operation of',def_interfaces_path)
        system_exit(1)
    ## Create a symlink from /etc/network/interfaces.static to /etc/network/interfaces
    x = os_symlink(static_interfaces_path,def_interfaces_path)
else:
    ## If the default 'interfaces' file already exists as a symlink,
    ## we will make sure to open with 'at', since we are modifying
    ## an already existing interfaces file with potentially active
    ## network interfaces
    x = check_file_islink(def_interfaces_path)
    if x == True:
        with open(def_interfaces_path, 'at') as f:
            f.write(template)
コード例 #7
0
    def ConfigureJB(self):
        if pathExists('%scomponents/zapNC.config' % PluginPath) is False:
            self.ZapNC=("1:0:1:1163:2AF8:13E:820000:0:0:0:")
        else:
            with open('%scomponents/zapNC.config' % PluginPath, 'r') as ZAPconfig:
                tmp=ZAPconfig.readline().split('"')[1]
                self.ZapNC=(tmp)
                ZAPconfig.close()
        if pathExists('%scomponents/zapCP.config' % PluginPath) is False:
            self.ZapCP=("1:0:1:332d:3390:71:820000:0:0:0:")
        else:
            with open('%scomponents/zapCP.config' % PluginPath, 'r') as ZAPconfig:
                tmp=ZAPconfig.readline().split('"')[1]
                self.ZapCP=(tmp)
                ZAPconfig.close()
        self.j00zekBouquetsNCBin='%scomponents/j00zekBouquetsNC%s' % (PluginPath,binType)
        self.j00zekBouquetsCPBin='%scomponents/j00zekBouquetsCP%s' % (PluginPath,binType)
        self.ExcludedSIDsTemplate='%scomponents/excludedSIDs.template' % PluginPath
        self.ExcludedSIDsFileName='userbouquet.excludedSIDs.j00zekAutobouquet.tv'
        self.ExcludedSIDsFile='/etc/enigma2/%s' % self.ExcludedSIDsFileName
        self.IncludedTranspondersTemplate='%scomponents/transponders.PL' % PluginPath
        self.IncludedTranspondersFile='/tmp/transponders.PL'
        self.runlist = []
        if pathExists('%s/components/CheckType.sh' % PluginPath) is True:
            self.runlist.append(('%s/components/CheckType.sh' % PluginPath))
        
        self.ZapTo=""
        
        #tylko polskie transpondery
        if config.plugins.GOS.j00zekBouquetsNC.value.endswith('PL'):
            if pathExists(self.IncludedTranspondersFile) is False:
                os_symlink(self.IncludedTranspondersTemplate,self.IncludedTranspondersFile)
        else:
            if pathExists(self.IncludedTranspondersFile) is True:
                os_remove(self.IncludedTranspondersFile)
        #kanaly do pominiecia
        if config.plugins.GOS.j00zekBouquetsExcludeBouquet.value == True:
            self.ExcludeSIDS="ExcludeSIDS"
            ExcludedSIDsFileNeedsUpdate=1
            if pathExists(self.ExcludedSIDsFile) is False:
                from shutil import copy as shutil_copy
                shutil_copy(self.ExcludedSIDsTemplate,self.ExcludedSIDsFile)
        else:
            self.ExcludeSIDS=""
            ExcludedSIDsFileNeedsUpdate=0
            
        #sprawdzamy schemat pliku bouquets.tv
        hasNewline=1
        if config.plugins.GOS.j00zekBouquetsNC.value !="NA":
            ncNeedsUpdate=1
        else:
            ncNeedsUpdate=0
        if config.plugins.GOS.j00zekBouquetsCP.value !="NA":
            cpNeedsUpdate=1
        else:
            cpNeedsUpdate=0
                
        windowsEOL=''
        with open("/etc/enigma2/bouquets.tv", "r") as bouquetsTV:
            for line in bouquetsTV:
                if windowsEOL == '' and line.endswith('\r\n'):
                    windowsEOL='\r'
                if line.endswith('\n'):
                    hasNewline=1
                else:
                    hasNewline=0
                if line.find(self.ExcludedSIDsFileName) > 0:
                    ExcludedSIDsFileNeedsUpdate=0
                if line.find('userbouquet.ncplus.j00zekAutobouquet.tv') > 0:
                    ncNeedsUpdate=0
                if line.find('userbouquet.CP.j00zekAutobouquet.tv') > 0:
                    cpNeedsUpdate=0
            bouquetsTV.close()
        #dopisujemy nasze bukiety
        if ncNeedsUpdate == 1:
            with open("/etc/enigma2/bouquets.tv", "a") as bouquetsTV:
                if hasNewline == 0:
                    bouquetsTV.write('\n')
                bouquetsTV.write('#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.ncplus.j00zekAutobouquet.tv" ORDER BY bouquet%s\n' % windowsEOL)
                bouquetsTV.close()
                hasNewline=1
            with open("/etc/enigma2/bouquets.radio", "a") as bouquetsTV:
                if hasNewline == 0:
                    bouquetsTV.write('\n')
                bouquetsTV.write('#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.ncplus.j00zekAutobouquet.radio" ORDER BY bouquet%s\n' % windowsEOL)
                bouquetsTV.close()
                hasNewline=1
        if cpNeedsUpdate == 1:
            with open("/etc/enigma2/bouquets.tv", "a") as bouquetsTV:
                if hasNewline == 0:
                    bouquetsTV.write('\n')
                bouquetsTV.write('#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.CP.j00zekAutobouquet.tv" ORDER BY bouquet%s\n' % windowsEOL)
                bouquetsTV.close()
                hasNewline=1
        if ExcludedSIDsFileNeedsUpdate == 1:
            with open("/etc/enigma2/bouquets.tv", "a") as bouquetsTV:
                if hasNewline == 0:
                    bouquetsTV.write('\n')
                bouquetsTV.write('#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "%s" ORDER BY bouquet%s\n' % (self.ExcludedSIDsFileName,windowsEOL))
                bouquetsTV.close()

        if config.plugins.GOS.j00zekBouquetsNC.value != 'NA':
            self.runlist.append("%s %s %s %s %s" % ( self.j00zekBouquetsNCBin, config.plugins.GOS.j00zekBouquetsNC.value, \
                                config.plugins.GOS.j00zekBouquetsAction.value, self.ZapNC, self.ExcludeSIDS))
            self.ZapTo=self.ZapNC
        if config.plugins.GOS.j00zekBouquetsCP.value != 'NA':
            self.runlist.append("%s %s %s %s %s" % ( self.j00zekBouquetsCPBin, config.plugins.GOS.j00zekBouquetsCP.value, \
                                config.plugins.GOS.j00zekBouquetsAction.value, self.ZapCP, self.ExcludeSIDS))
            if self.ZapTo == "":
                self.ZapTo = self.ZapCP
コード例 #8
0
ファイル: hacks.py プロジェクト: wangfan008/cerbero
def symlink(src, dst, **kwargs):
    src = str(WindowsPath(src))
    os_symlink(src, dst, **kwargs)
コード例 #9
0
ファイル: j00zekBouquets.py プロジェクト: sarada/eePlugins
 def ConfigureJB(self):
     if pathExists('%scomponents/zapNC.config' % PluginPath) is False:
         self.ZapNC=("1:0:1:1139:2AF8:13E:820000:0:0:0:")
     else:
         with open('%scomponents/zapNC.config' % PluginPath, 'r') as ZAPconfig:
             tmp=ZAPconfig.readline().split('"')[1]
             self.ZapNC=(tmp)
             ZAPconfig.close()
     if pathExists('%scomponents/zapCP.config' % PluginPath) is False:
         self.ZapCP=("1:0:1:3396:3390:71:820000:0:0:0:")
     else:
         with open('%scomponents/zapCP.config' % PluginPath, 'r') as ZAPconfig:
             tmp=ZAPconfig.readline().split('"')[1]
             self.ZapCP=(tmp)
             ZAPconfig.close()
     self.BouquetsNCBin='%scomponents/j00zekBouquetsNC' % (PluginPath)
     self.BouquetsCPBin='%scomponents/j00zekBouquetsCP' % (PluginPath)
     self.ExcludedSIDsTemplate='%scomponents/excludedSIDs.template' % PluginPath
     self.ExcludedSIDsFileName='userbouquet.excludedSIDs.j00zekAutobouquet.tv'
     self.ExcludedSIDsFile='/etc/enigma2/%s' % self.ExcludedSIDsFileName
     self.IncludedTranspondersTemplate='%scomponents/PLtransponders.cfg' % PluginPath
     self.IncludedTranspondersFile='/tmp/transponders.PL'
     self.runlist = []
     self.runlist.append(('[ -f /tmp/.ChannelsNotUpdated ] && rm -f /tmp/.ChannelsNotUpdated 2>/dev/null'))
     if pathExists('%s/components/CheckType.sh' % PluginPath) is True:
         self.runlist.append(('chmod 755 %s/components/*.sh' % PluginPath))
         self.runlist.append(('%s/components/CheckType.sh' % PluginPath))
     
     self.ZapTo=""
     
     #tylko polskie transpondery
     if j00zekConfig.BouquetsNC.value.endswith('PL'):
         if not pathExists(self.IncludedTranspondersFile):
             os_symlink(self.IncludedTranspondersTemplate,self.IncludedTranspondersFile)
     else:
         if pathExists(self.IncludedTranspondersFile):
             os_remove(self.IncludedTranspondersFile)
     #kanaly do pominiecia
     if j00zekConfig.BouquetsExcludeBouquet.value == True:
         self.ExcludeSIDS="1"
         ExcludedSIDsFileNeedsUpdate=1
         if pathExists(self.ExcludedSIDsFile) is False:
             from shutil import copy as shutil_copy
             shutil_copy(self.ExcludedSIDsTemplate,self.ExcludedSIDsFile)
     else:
         self.ExcludeSIDS="0"
         ExcludedSIDsFileNeedsUpdate=0
         
     #sprawdzamy schemat pliku bouquets.tv
     hasNewline=1
     if j00zekConfig.BouquetsNC.value !="NA":
         ncNeedsUpdate=1
     else:
         ncNeedsUpdate=0
     if j00zekConfig.BouquetsCP.value !="NA":
         cpNeedsUpdate=1
     else:
         cpNeedsUpdate=0
             
     windowsEOL=''
     with open("/etc/enigma2/bouquets.tv", "r") as bouquetsTV:
         for line in bouquetsTV:
             if windowsEOL == '' and line.endswith('\r\n'):
                 windowsEOL='\r'
             if line.endswith('\n'):
                 hasNewline=1
             else:
                 hasNewline=0
             if line.find(self.ExcludedSIDsFileName) > 0:
                 ExcludedSIDsFileNeedsUpdate=0
             if line.find('userbouquet.ncplus.j00zekAutobouquet.tv') > 0:
                 ncNeedsUpdate=0
             if line.find('userbouquet.CP.j00zekAutobouquet.tv') > 0:
                 cpNeedsUpdate=0
         bouquetsTV.close()
     #dopisujemy nasze bukiety
     if ncNeedsUpdate == 1:
         with open("/etc/enigma2/bouquets.tv", "a") as bouquetsTV:
             if hasNewline == 0:
                 bouquetsTV.write('\n')
             bouquetsTV.write('#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.ncplus.j00zekAutobouquet.tv" ORDER BY bouquet%s\n' % windowsEOL)
             bouquetsTV.close()
             hasNewline=1
     if cpNeedsUpdate == 1:
         with open("/etc/enigma2/bouquets.tv", "a") as bouquetsTV:
             if hasNewline == 0:
                 bouquetsTV.write('\n')
             bouquetsTV.write('#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.CP.j00zekAutobouquet.tv" ORDER BY bouquet%s\n' % windowsEOL)
             bouquetsTV.close()
             hasNewline=1
     if ExcludedSIDsFileNeedsUpdate == 1:
         with open("/etc/enigma2/bouquets.tv", "a") as bouquetsTV:
             if hasNewline == 0:
                 bouquetsTV.write('\n')
             bouquetsTV.write('#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "%s" ORDER BY bouquet%s\n' % (self.ExcludedSIDsFileName,windowsEOL))
             bouquetsTV.close()
     
     if j00zekConfig.BouquetsNC.value == '49188PL' and j00zekConfig.syncPLtransponders.value == True:
          self.runlist.append('%scomponents/SyncFromWeb.sh' % PluginPath)
     if j00zekConfig.BouquetsNC.value != 'NA':
         self.runlist.append("%s %s %s %s %s '%s'" % ( self.BouquetsNCBin, j00zekConfig.BouquetsNC.value, \
                             j00zekConfig.BouquetsAction.value, self.ZapNC, self.ExcludeSIDS, j00zekConfig.Znacznik.value))
         self.ZapTo=self.ZapNC
     if j00zekConfig.BouquetsCP.value != 'NA':
         self.runlist.append("%s %s %s %s %s '%s'" % ( self.BouquetsCPBin, j00zekConfig.BouquetsCP.value, \
                             j00zekConfig.BouquetsAction.value, self.ZapCP, self.ExcludeSIDS, j00zekConfig.Znacznik.value))
         if self.ZapTo == "":
             self.ZapTo = self.ZapCP
     if j00zekConfig.BouquetsAction.value in ("1st","all") and  j00zekConfig.Clear1st.value == True:
         self.runlist.append(('%s/components/clear1st.sh' % PluginPath))
     if j00zekConfig.ClearBouquets.value:
         self.runlist.append("%s/components/ClearBouquets" % PluginPath)
     return
コード例 #10
0
ファイル: fabfile.py プロジェクト: goryszewskig/rt-graphite
def configure():
    graph_conf_path='/opt/graphite/conf'
    graph_stor_path = '/opt/graphite/storage'
    apache_avail = '/etc/apache2/sites-available'
    apache_enab = '/etc/apache2/sites-enabled'
    apache_src_conf = '/root/default-graphite'
    apache_dst_conf = "{0}/{1}".format(apache_avail,'default-graphite')
    apache_enab_conf = "{0}/{1}".format(apache_enab,'default-graphite')
    stor_sch_conf = "{0}/{1}".format(graph_conf_path,'storage-schemas.conf')

    with settings(
        show('running',
             'stdout',
             'stderr'),
        warn_only=True, always_use_pty='false'):

        for file in ['carbon.conf','storage-schemas.conf','graphite.wsgi']:

            src = "{0}/{1}.example".format(graph_conf_path,file)
            dst = "{0}/{1}".format(graph_conf_path,file)
            ## Copy from example, template to real file
            copyfile(src,dst)

        ## Generate default-graphite apache config file, based on
        ## template at top of this file.
        make_apache_conf = Template(apache_base_templ)

        ## Write template into the new config file
        ## /etc/apache2/sites-available/default-graphite

        try:
            open(apache_dst_conf,'wt').write(
                make_apache_conf.substitute(port=80,wsgi_sockd='/etc/httpd/wsgi/')
            )
            fab_puts("Wrote apache config for Graphite WebApp.",show_prefix=False)

        except IOError as e:
            fab_abort("Error {0} Failed to open file {1}".format(e.errno,e.filename))

        try:
            open(stor_sch_conf,'at').write(stor_base_templ)
            fab_puts("Updated storage schema config with brickstor elements.",show_prefix=False)

        except IOError as e:
            fab_abort("Error {0} Failed to open file {1}".format(e.errno,e.filename))

        try:
            os_remove('/etc/apache2/sites-enabled/000-default')
        except OSError as e:
            print "Warning: {0} {1}".format(e.filename,e.args)

        ## Create necessary directories for Apache
        for dir in ['/etc/httpd','/etc/httpd/wsgi']:
            try:
                os_mkdir(dir,0755)
                fab_puts("Created directory: {0}".format(dir),show_prefix=False)
            except OSError as e:
                print "Warning: {0} {1}".format(e.filename,e.args)

        try:
            os_symlink(apache_dst_conf, apache_enab_conf)
            fab_puts("Created symbolic link for {0}".format(apache_dst_conf),show_prefix=False)

        except OSError as e:
            print "Warning: {0} {1}".format(e.filename,e.args)

        with fab_lcd('/opt/graphite/webapp/graphite/'):
            fab_local('python manage.py syncdb')

        ## This should really use python os module, will fix later.
        fab_local("chown -R {0} {1}".format('www-data:www-data',graph_stor_path))

        ## Copy local_settings.py.example config into real config file
        src = '/opt/graphite/webapp/graphite/local_settings.py.example'
        dst = '/opt/graphite/webapp/graphite/local_settings.py'
        copyfile(src,dst)

        ## Reload Apache config after all the changes
        fab_local("/etc/init.d/apache2 reload")
コード例 #11
0
## If the 'interfaces.static' file does not exist, we need
## to create it, since we will write new config to it
## and we will symlink it via /etc/network/interfaces
if not check_ifcfg_file_exists(static_interfaces_path):
    x = touch_file(static_interfaces_path)
    ## If we cannot successfully create 'interfaces.static' file
    ## we need to bail here
    if x == False:
        system_exit(1)
    ## Assuming we got this far, we can now write our pre-defined template
    ## to the 'interfaces.static' file
    with open(static_interfaces_path, 'wt') as f:
        f.write(template)
if check_ifcfg_file_exists(
        def_interfaces_path) and not check_file_islink(def_interfaces_path):
    x = rename_file(def_interfaces_path, new_def_interfaces_path)
    if not x:
        print '%s %s' % ('Failed with rename operation of',
                         def_interfaces_path)
        system_exit(1)
    ## Create a symlink from /etc/network/interfaces.static to /etc/network/interfaces
    x = os_symlink(static_interfaces_path, def_interfaces_path)
else:
    ## If the default 'interfaces' file already exists as a symlink,
    ## we will make sure to open with 'at', since we are modifying
    ## an already existing interfaces file with potentially active
    ## network interfaces
    x = check_file_islink(def_interfaces_path)
    if x == True:
        with open(def_interfaces_path, 'at') as f:
            f.write(template)
コード例 #12
0
    def ConfigureJB(self):
        if pathExists('%scomponents/zapNC.config' % PluginPath) is False:
            self.ZapNC = ("1:0:1:1163:2AF8:13E:820000:0:0:0:")
        else:
            with open('%scomponents/zapNC.config' % PluginPath,
                      'r') as ZAPconfig:
                tmp = ZAPconfig.readline().split('"')[1]
                self.ZapNC = (tmp)
                ZAPconfig.close()
        if pathExists('%scomponents/zapCP.config' % PluginPath) is False:
            self.ZapCP = ("1:0:1:332d:3390:71:820000:0:0:0:")
        else:
            with open('%scomponents/zapCP.config' % PluginPath,
                      'r') as ZAPconfig:
                tmp = ZAPconfig.readline().split('"')[1]
                self.ZapCP = (tmp)
                ZAPconfig.close()
        self.j00zekBouquetsNCBin = '%scomponents/j00zekBouquetsNC%s' % (
            PluginPath, binType)
        self.j00zekBouquetsCPBin = '%scomponents/j00zekBouquetsCP%s' % (
            PluginPath, binType)
        self.ExcludedSIDsTemplate = '%scomponents/excludedSIDs.template' % PluginPath
        self.ExcludedSIDsFileName = 'userbouquet.excludedSIDs.j00zekAutobouquet.tv'
        self.ExcludedSIDsFile = '/etc/enigma2/%s' % self.ExcludedSIDsFileName
        self.IncludedTranspondersTemplate = '%scomponents/transponders.PL' % PluginPath
        self.IncludedTranspondersFile = '/tmp/transponders.PL'
        self.runlist = []
        if pathExists('%s/components/CheckType.sh' % PluginPath) is True:
            self.runlist.append(('%s/components/CheckType.sh' % PluginPath))

        self.ZapTo = ""

        #tylko polskie transpondery
        if config.plugins.GOS.j00zekBouquetsNC.value.endswith('PL'):
            if pathExists(self.IncludedTranspondersFile) is False:
                os_symlink(self.IncludedTranspondersTemplate,
                           self.IncludedTranspondersFile)
        else:
            if pathExists(self.IncludedTranspondersFile) is True:
                os_remove(self.IncludedTranspondersFile)
        #kanaly do pominiecia
        if config.plugins.GOS.j00zekBouquetsExcludeBouquet.value == True:
            self.ExcludeSIDS = "ExcludeSIDS"
            ExcludedSIDsFileNeedsUpdate = 1
            if pathExists(self.ExcludedSIDsFile) is False:
                from shutil import copy as shutil_copy
                shutil_copy(self.ExcludedSIDsTemplate, self.ExcludedSIDsFile)
        else:
            self.ExcludeSIDS = ""
            ExcludedSIDsFileNeedsUpdate = 0

        #sprawdzamy schemat pliku bouquets.tv
        hasNewline = 1
        if config.plugins.GOS.j00zekBouquetsNC.value != "NA":
            ncNeedsUpdate = 1
        else:
            ncNeedsUpdate = 0
        if config.plugins.GOS.j00zekBouquetsCP.value != "NA":
            cpNeedsUpdate = 1
        else:
            cpNeedsUpdate = 0

        windowsEOL = ''
        with open("/etc/enigma2/bouquets.tv", "r") as bouquetsTV:
            for line in bouquetsTV:
                if windowsEOL == '' and line.endswith('\r\n'):
                    windowsEOL = '\r'
                if line.endswith('\n'):
                    hasNewline = 1
                else:
                    hasNewline = 0
                if line.find(self.ExcludedSIDsFileName) > 0:
                    ExcludedSIDsFileNeedsUpdate = 0
                if line.find('userbouquet.ncplus.j00zekAutobouquet.tv') > 0:
                    ncNeedsUpdate = 0
                if line.find('userbouquet.CP.j00zekAutobouquet.tv') > 0:
                    cpNeedsUpdate = 0
            bouquetsTV.close()
        #dopisujemy nasze bukiety
        if ncNeedsUpdate == 1:
            with open("/etc/enigma2/bouquets.tv", "a") as bouquetsTV:
                if hasNewline == 0:
                    bouquetsTV.write('\n')
                bouquetsTV.write(
                    '#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.ncplus.j00zekAutobouquet.tv" ORDER BY bouquet%s\n'
                    % windowsEOL)
                bouquetsTV.close()
                hasNewline = 1
            with open("/etc/enigma2/bouquets.radio", "a") as bouquetsTV:
                if hasNewline == 0:
                    bouquetsTV.write('\n')
                bouquetsTV.write(
                    '#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.ncplus.j00zekAutobouquet.radio" ORDER BY bouquet%s\n'
                    % windowsEOL)
                bouquetsTV.close()
                hasNewline = 1
        if cpNeedsUpdate == 1:
            with open("/etc/enigma2/bouquets.tv", "a") as bouquetsTV:
                if hasNewline == 0:
                    bouquetsTV.write('\n')
                bouquetsTV.write(
                    '#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "userbouquet.CP.j00zekAutobouquet.tv" ORDER BY bouquet%s\n'
                    % windowsEOL)
                bouquetsTV.close()
                hasNewline = 1
        if ExcludedSIDsFileNeedsUpdate == 1:
            with open("/etc/enigma2/bouquets.tv", "a") as bouquetsTV:
                if hasNewline == 0:
                    bouquetsTV.write('\n')
                bouquetsTV.write(
                    '#SERVICE 1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "%s" ORDER BY bouquet%s\n'
                    % (self.ExcludedSIDsFileName, windowsEOL))
                bouquetsTV.close()

        if config.plugins.GOS.j00zekBouquetsNC.value != 'NA':
            self.runlist.append("%s %s %s %s %s" % ( self.j00zekBouquetsNCBin, config.plugins.GOS.j00zekBouquetsNC.value, \
                                config.plugins.GOS.j00zekBouquetsAction.value, self.ZapNC, self.ExcludeSIDS))
            self.ZapTo = self.ZapNC
        if config.plugins.GOS.j00zekBouquetsCP.value != 'NA':
            self.runlist.append("%s %s %s %s %s" % ( self.j00zekBouquetsCPBin, config.plugins.GOS.j00zekBouquetsCP.value, \
                                config.plugins.GOS.j00zekBouquetsAction.value, self.ZapCP, self.ExcludeSIDS))
            if self.ZapTo == "":
                self.ZapTo = self.ZapCP