summaryrefslogtreecommitdiffstats
path: root/linhes/linhes-system/remove_storage.py
diff options
context:
space:
mode:
Diffstat (limited to 'linhes/linhes-system/remove_storage.py')
-rwxr-xr-xlinhes/linhes-system/remove_storage.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/linhes/linhes-system/remove_storage.py b/linhes/linhes-system/remove_storage.py
index 15dbffc..5de2f7a 100755
--- a/linhes/linhes-system/remove_storage.py
+++ b/linhes/linhes-system/remove_storage.py
@@ -1,13 +1,13 @@
-#!/usr/bin/python2
+#!/usr/bin/python
#remove_storage.py removes disks that were added using add_storage.py
#
#Only disks that have a conf file in /etc/storage.d/ are presented
#as choices to remove.
-
+# Version 2.0.0
import os,sys,subprocess
import configparser
-from configparser import SafeConfigParser
+from configparser import ConfigParser
import glob
from socket import gethostname
from MythTV import MythDB
@@ -69,15 +69,13 @@ def remove_disk_mount(conf):
runcmd(cmd)
def update_conf_file(conf):
- print("Updating %s file\n and running systemconfig." %(conf[4]))
- parser = SafeConfigParser()
+ print("Updating %s file." %(conf[4]))
+ parser = ConfigParser()
parser.read(conf[4])
parser.set('storage','shareable',"False")
parser.set('storage','removed',"True")
- with open(conf[4], 'wb') as conf[4]:
+ with open(conf[4], 'w') as conf[4]:
parser.write(conf[4])
- cmd = "systemconfig.py -m fileshare"
- runcmd(cmd)
def usage():
help='''
@@ -96,7 +94,6 @@ def usage():
Remove disk name mountpoint at /data/storage/
Make shareable = False in /etc/storage.d/DISKNAME.conf
Add removed = True in /etc/stoarge.d/DISKNAME.conf
- Run systemconfig.py -m fileshare to update File Shares
Options:
-h, --help: Show this help message.
@@ -112,10 +109,14 @@ def main():
# get conf files that are not disk0 or not removed
for conf_file in glob.glob('%s/*.conf' %storage_dir):
this_conf = []
- parser = SafeConfigParser()
+ parser = ConfigParser()
parser.read(conf_file)
mounted = ""
- disk_num = parser.get('storage', 'disk_num')
+ try:
+ disk_num = parser.get('storage', 'disk_num')
+ except:
+ print("\nSkipping: " + conf_file + " is missing disk_num")
+ continue
try:
removed = parser.get('storage', 'removed')
except: