diff options
author | James Meyer <james.meyer@operamail.com> | 2012-10-09 13:43:54 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2012-10-09 13:43:54 (GMT) |
commit | 897a2d12a668cffcc3f6d1a97807ae6edeea5881 (patch) | |
tree | 4c116101770f039ccb1e14e133b5f8aa19705769 /abs | |
parent | db0026e9d2a62dd9ab65d016ef1e30735c0d460c (diff) | |
download | linhes_pkgbuild-897a2d12a668cffcc3f6d1a97807ae6edeea5881.zip linhes_pkgbuild-897a2d12a668cffcc3f6d1a97807ae6edeea5881.tar.gz linhes_pkgbuild-897a2d12a668cffcc3f6d1a97807ae6edeea5881.tar.bz2 |
LinHES-config: timezip.py do not overwrite most settings if a value is already present.
-several formating changes and cleanup
Diffstat (limited to 'abs')
-rwxr-xr-x | abs/core/LinHES-config/PKGBUILD | 4 | ||||
-rwxr-xr-x | abs/core/LinHES-config/timezip.py | 298 |
2 files changed, 189 insertions, 113 deletions
diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD index df69f79..ebbabdc 100755 --- a/abs/core/LinHES-config/PKGBUILD +++ b/abs/core/LinHES-config/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-config pkgver=2.3 -pkgrel=169 +pkgrel=170 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev LinHes-config ) pkgdesc="Install and configure your system" depends=('bc' 'libstatgrab' 'mysql-python' 'expect' 'curl' 'dnsutils' 'parted' @@ -137,7 +137,7 @@ md5sums=('59e18e35359bebcd9d639c5e5b5d290d' '2a7f3b34e522acfd08283b86c8926aba' '36f5017e25c200354a954b17819aa1b2' '689b01f7636e09b2f9657c6ce6006ee7' - '38d17b5415c9fce98923a1b136a3fbe0' + '54d68963d5560489dd9e642a7c600540' 'a6faa20d905e2fd92ce79acab044b759' '8ba06c2ce6129371548cc360ccca27f8' '5f890ea9bda6aef652d2560ca19dac07' diff --git a/abs/core/LinHES-config/timezip.py b/abs/core/LinHES-config/timezip.py index 89b95de..82efefc 100755 --- a/abs/core/LinHES-config/timezip.py +++ b/abs/core/LinHES-config/timezip.py @@ -23,6 +23,8 @@ except ImportError: raise RuntimeError("Neither the json or simplejson module is available.\nUse the --unsafe option to use python eval() as an ad-hoc json decoder") +def no_update(data): + print "* not updating %s, because a value is already present" %data @@ -79,16 +81,23 @@ def printvars(): print "installdb:" + installdb print "hostname: " + thishostname print "BEhostname:" + BEhostname - print "zipcode:" + zipcode + #print "zipcode:" + zipcode print "timezone:" + tz print "timezone region:" + tz_region print "timezone subregion:" + tz_subregion print "nfsip:" + nfsip - print "nfstoggle:" + nfstoggle + #print "nfstoggle:" + nfstoggle print "nfsmount:" + nfsmount - print "hobbitclient:" + hobbitclient + #print "hobbitclient:" + hobbitclient print "windowmanager:" + windowmanager print "windowmanager style:" + wmstyle + print "Gallery Dir:" + gallerydir + print "Music dir:" + musicdir + print "Music template:" + filenametemplate + print "-----------------------------------" + print "\n\n\n" + + # connect def selectvars(): @@ -98,168 +107,197 @@ def selectvars(): global tz_region global tz_subregion global nfsip - global nfstoggle + #global nfstoggle global nfsmount - global hobbitclient + #global hobbitclient global windowmanager global wmstyle + global musicdir + global gallerydir + global filenametemplate db = MySQLdb.connect(host=masterdb, user="mythtv", passwd="mythtv", db="mythconverg") # create a cursor cursor = db.cursor() # execute SQL statement - cursor.execute("select hostname from settings where value='BackendServerIP' and data=(%s)",(masterdb)) - result = cursor.fetchone() + try: + cursor.execute("select hostname from settings where value='BackendServerIP' and data=(%s)",(masterdb)) + result = cursor.fetchone() BEhostname=result[0] except TypeError: BEhostname="" - cursor.execute("select data from settings where value='HostZipcode' and hostname=(%s)",(BEhostname)) - result = cursor.fetchone() - try: - zipcode = result[0] - except TypeError: - zipcode="" - - cursor.execute("select data from settings where value='HostCentralNFSIP' and hostname=(%s)",(BEhostname)) - result = cursor.fetchone() try: + cursor.execute("select data from settings where value='HostCentralNFSIP' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() nfsip=result[0] except TypeError: nfsip="" - cursor.execute("select data from settings where value='HostHaveCentralNFS' and hostname=(%s)",(BEhostname)) - result = cursor.fetchone() - try: - nfstoggle=result[0] - except TypeError: - nfstoggle="" + #cursor.execute("select data from settings where value='HostHaveCentralNFS' and hostname=(%s)",(BEhostname)) + #result = cursor.fetchone() + #try: + #nfstoggle=result[0] + #except TypeError: + #nfstoggle="" + - cursor.execute("select data from settings where value='HostNFSmountpoint' and hostname=(%s)",(BEhostname)) - result = cursor.fetchone() try: + cursor.execute("select data from settings where value='HostNFSmountpoint' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() nfsmount=result[0] except TypeError: nfsmount="" - cursor.execute("select data from settings where value='HostTimeZonetemp' and hostname=(%s)",(BEhostname)) - #cursor.execute("select data from settings where value='HostTimeZone' and hostname=(%s)",(BEhostname)) - result = cursor.fetchone() + try: + #cursor.execute("select data from settings where value='HostTimeZonetemp' and hostname=(%s)",(BEhostname)) + cursor.execute("select data from settings where value='HostTimeZone' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() tz=result[0] except TypeError: - tz="" + tz = "" if tz == "": tz,tz_region, tz_subregion = geo_locate() else: - cursor.execute("select data from settings where value='HostTimeZoneRegion' and hostname=(%s)",(BEhostname)) - result = cursor.fetchone() try: + cursor.execute("select data from settings where value='HostTimeZoneRegion' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() tz_region=result[0] except TypeError: tz_region="" tempsubregion="HostTimeZoneRegion_" + tz_region - - cursor.execute("select data from settings where value=%s and hostname=(%s)",(tempsubregion,BEhostname)) - result = cursor.fetchone() try: + cursor.execute("select data from settings where value=%s and hostname=(%s)",(tempsubregion,BEhostname)) + result = cursor.fetchone() tz_subregion=result[0] except TypeError: tz_subregion="" ############### - if ( thishostname != BEhostname ): - cursor.execute("select data from settings where value='GlobalServiceHobbitserver'") - result = cursor.fetchone() - try: - hobbitclient=result[0] - except: - hobbitclient="1" - else: - hobbitclient="1" + #if ( thishostname != BEhostname ): + #cursor.execute("select data from settings where value='GlobalServiceHobbitserver'") + #result = cursor.fetchone() + #try: + #hobbitclient=result[0] + #except: + #hobbitclient="1" + #else: + #hobbitclient="1" + - cursor.execute("select data from settings where value='HostWindowManager' and hostname=(%s)",(BEhostname)) - result = cursor.fetchone() try: + cursor.execute("select data from settings where value='HostWindowManager' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() windowmanager=result[0] except TypeError: - windowmanager="default" + windowmanager="" + - cursor.execute("select data from settings where value='HostEnhancedWMStyle' and hostname=(%s)",(BEhostname)) - result = cursor.fetchone() try: + cursor.execute("select data from settings where value='HostEnhancedWMStyle' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() wmstyle=result[0] except TypeError: - wmstyle="0" + wmstyle="" + + + try: + cursor.execute("select data from settings where value='MusicLocation' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() + musicdir=result[0] + except TypeError: + musicdir="" + + + try: + cursor.execute("select data from settings where value='FilenameTemplate' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() + filenametemplate=result[0] + except TypeError: + filenametemplate="" + + + try: + cursor.execute("select data from settings where value='GalleryDir' and hostname=(%s)",(BEhostname)) + result = cursor.fetchone() + gallerydir=result[0] + except TypeError: + gallerydir="" def insertvars(): db = MySQLdb.connect(host=installdb, user="mythtv", passwd="mythtv", db="mythconverg") cursor = db.cursor() -#inserting the zipcode - cursor.execute("select * from settings where value='HostZipcode' and hostname=(%s)",(thishostname)) - result = cursor.fetchone() - if ( zipcode!="" ): - if (result == None): - cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostZipcode',(%s),(%s))",(zipcode,thishostname)) - print "inserting zipcode" - else: - cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostZipcode'",(zipcode,thishostname)) - print "updating zipcode" +##inserting the zipcode + #cursor.execute("select * from settings where value='HostZipcode' and hostname=(%s)",(thishostname)) + #result = cursor.fetchone() + #if ( zipcode!="" ): + #if (result == None): + #cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostZipcode',(%s),(%s))",(zipcode,thishostname)) + #print "inserting zipcode" + #else: + #cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostZipcode'",(zipcode,thishostname)) + #print "updating zipcode" #inserting the timezone - cursor.execute("select * from settings where value='HostTimeZone' and hostname=(%s)",(thishostname)) - result = cursor.fetchone() + if ( tz != ""): - if (result == None): + cursor.execute("select * from settings where value='HostTimeZone' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if (result == None): cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostTimeZone',(%s),(%s))",(tz,thishostname)) print "inserting timezone" - else: + else: cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostTimeZone'",(tz,thishostname)) print "updating timezone" - cursor.execute("select * from settings where value='HostTimeZoneRegion' and hostname=(%s)",(thishostname)) - result = cursor.fetchone() - if ( tz != ""): - if (result == None): + cursor.execute("select * from settings where value='HostTimeZoneRegion' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if (result == None): cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostTimeZoneRegion',(%s),(%s))",(tz_region,thishostname)) print "inserting timezone region" - else: + else: cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostTimeZoneRegion'",(tz_region,thishostname)) print "updating timezone region" - tempsubregion="HostTimeZoneRegion_" + tz_region - cursor.execute("select * from settings where value=%s and hostname=(%s)",(tempsubregion,thishostname)) - result = cursor.fetchone() - if ( tz != ""): - if (result == None): + tempsubregion="HostTimeZoneRegion_" + tz_region + + cursor.execute("select * from settings where value=%s and hostname=(%s)",(tempsubregion,thishostname)) + result = cursor.fetchone() + if (result == None): cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ((%s),(%s),(%s))",(tempsubregion,tz_subregion,thishostname)) print "inserting timezone subregion" - else: - cursor.execute("update settings set data=(%s) where hostname=(%s) and value=(%s)",(tempsubregion,tz_subregion,thishostname)) + else: + cursor.execute("update settings set data=(%s) where hostname=(%s) and value=(%s)",(tz_subregion,thishostname,tempsubregion)) print "updating timezone subregion" -#start of NFSIP - cursor.execute("select data from settings where value='HostCentralNFSIP' and hostname=(%s)",(thishostname)) - result = cursor.fetchone() +##start of NFSIP + if ( nfsip != ""): + cursor.execute("select data from settings where value='HostCentralNFSIP' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() if (result == None): cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostCentralNFSIP',(%s),(%s))",(nfsip,thishostname)) print "inserting nfsip" + else: + no_update("HostCentralNFSIP") + #cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostCentralNFSIP'",(nfsip,thishostname)) + #print "updating nfsip" - if (nfstoggle != ""): - cursor.execute("select data from settings where value='HostHaveCentralNFS' and hostname=(%s)",(thishostname)) - result = cursor.fetchone() - if (result == None): - cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostHaveCentralNFS',(%s),(%s))",(nfstoggle,thishostname)) - print "inserting nfstoggle" + #if (nfstoggle != ""): + #cursor.execute("select data from settings where value='HostHaveCentralNFS' and hostname=(%s)",(thishostname)) + #result = cursor.fetchone() + #if (result == None): + #cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostHaveCentralNFS',(%s),(%s))",(nfstoggle,thishostname)) + #print "inserting nfstoggle" if ( nfsmount !="") : cursor.execute("select data from settings where value='HostNFSmountpoint' and hostname=(%s)",(thishostname)) @@ -267,37 +305,72 @@ def insertvars(): if (result == None): cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostNFSmountpoint',(%s),(%s))",(nfsmount,thishostname)) print "inserting nfsmountpoint" + else: + no_update("nfsmount") + #cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostNFSmountpoint'",(nfsmount,thishostname)) + #print "updating nfsmount" -#hobbitclient - cursor.execute("select * from settings where value='HostServiceHobbitclient' and hostname=(%s)",(thishostname)) - result = cursor.fetchone() - if ( hobbitclient != ""): - if (result == None): - cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostServiceHobbitclient',(%s),(%s))",(hobbitclient,thishostname)) - print "inserting hobbitcleint" - else: - cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostServiceHobbitclient'",(hobbitclient,thishostname)) - print "updating hobbitclient" #windowmanager - cursor.execute("select * from settings where value='HostWindowManager' and hostname=(%s)",(thishostname)) - result = cursor.fetchone() - if (result == None): - cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostWindowManager',(%s),(%s))",(windowmanager,thishostname)) - print "inserting windowmanager" - else: - cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostWindowManager'",(windowmanager,thishostname)) - print "updating windowmanager" + if windowmanager != "": + cursor.execute("select * from settings where value='HostWindowManager' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostWindowManager',(%s),(%s))",(windowmanager,thishostname)) + print "inserting windowmanager" + else: + no_update("windowmanager") + #cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostWindowManager'",(windowmanager,thishostname)) + #print "updating windowmanager" + + + if wmstyle != "" : + cursor.execute("select * from settings where value='HostEnhancedWMStyle' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostEnhancedWMStyle',(%s),(%s))",(wmstyle,thishostname)) + print "inserting windowmanager style" + else: + no_update("wm_style") + #cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostEnhancedWMStyle'",(wmstyle,thishostname)) + #print "updating windowmanager style" + +#music and gallery + + if ( musicdir != "" ): + cursor.execute("select * from settings where value='MusicLocation' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('MusicLocation',(%s),(%s))",(musicdir,thishostname)) + print "inserting musicdir" + else: + no_update("musicdir") + #cursor.execute("update settings set data=(%s) where hostname=(%s) and value='MusicLocation'",(musicdir,thishostname)) + #print "updating musicdir" + + if ( filenametemplate != "" ): + cursor.execute("select * from settings where value='FilenameTemplate' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('FilenameTemplate',(%s),(%s))",(filenametemplate,thishostname)) + print "inserting filenametemplate" + else: + no_update("filenametemplate") + #cursor.execute("update settings set data=(%s) where hostname=(%s) and value='FilenameTemplate'",(filenametemplate,thishostname)) + #print "updating filenametemplate" + + if ( gallerydir != "" ): + cursor.execute("select * from settings where value='GalleryDir' and hostname=(%s)",(thishostname)) + result = cursor.fetchone() + if (result == None): + cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('GalleryDir',(%s),(%s))",(gallerydir,thishostname)) + print "inserting gallerydir" + else: + no_update("gallerydir") + #cursor.execute("update settings set data=(%s) where hostname=(%s) and value='GalleryDir'",(gallerydir,thishostname)) + #print "updating gallerydir" - cursor.execute("select * from settings where value='HostEnhancedWMStyle' and hostname=(%s)",(thishostname)) - result = cursor.fetchone() - if (result == None): - cursor.execute("INSERT INTO settings (value,data,hostname) VALUES ('HostEnhancedWMStyle',(%s),(%s))",(wmstyle,thishostname)) - print "inserting windowmanager style" - else: - cursor.execute("update settings set data=(%s) where hostname=(%s) and value='HostEnhancedWMStyle'",(wmstyle,thishostname)) - print "updating windowmanager style" def main(argv): @@ -310,8 +383,11 @@ def main(argv): global tz global tz_region global tz_subregion - global nfsip - global hobbitclient + #global nfsip + #global hobbitclient + global musicdir + global gallerydir + global filenametemplate try: opts, args = getopt.getopt(argv, "hm:d:n:", ["help", "masterdb=", "installdb=" , "hostname=" ] ) |