From 212f213a096bfd0ae61319dab277e74c845b1d60 Mon Sep 17 00:00:00 2001 From: fling Date: Fri, 15 Oct 2010 13:41:32 +0800 Subject: [PATCH] modified: ri_oper.py --- interface/ri_oper.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/interface/ri_oper.py b/interface/ri_oper.py index 9b7ddca..ba72aa4 100644 --- a/interface/ri_oper.py +++ b/interface/ri_oper.py @@ -52,7 +52,7 @@ class Operation: and the following methods: get_arguments - prepare arguments for scipt get_stdin - prepare stdin for script - install - install progress ''' + install - install progress ''' def __init__(self,e,c,s,scr): ''' Operation(base class) init method @@ -77,7 +77,7 @@ class Operation: max = Rate.value+self.score <100 and Rate.value+self.score or 100 process = subprocess.Popen("./%s " %self.script + ' '.join(self.get_arguments()),\ stdin=subprocess.PIPE,stdout=subprocess.PIPE, shell=True, \ - cwd="%s/../operation"%os.path.split(os.path.realpath(__file__))[0]) + cwd="%s/../operation" %os.path.split(os.path.realpath(__file__))[0]) process.stdin.write(self.get_stdin()) process.stdin.close() while True: @@ -118,7 +118,6 @@ class Format(Operation): class MakeRaid(Operation): """class for make raid""" - flag=False def __init__(self,scr): Operation.__init__(self,"make RAID",u"正在制作RAID磁盘阵列","mkraid_wrapper.sh",scr) def get_stdin(self): @@ -126,7 +125,6 @@ class MakeRaid(Operation): n = 0 for instance in ri_data.Raid.list: if instance.from_os == 'no': - MakeRaid.flag=True args += '-n /dev/%s -l %s -s %s -a %s\n' %(instance.device, instance.level, \ ','.join([ '/dev/%s' %sp for sp in instance.spare_components]), \ ','.join([ '/dev/%s' %ac for ac in instance.active_components])) @@ -139,8 +137,8 @@ class MakeRaidConfigure(Operation): def __init__(self,scr): Operation.__init__(self,"make raid configure file",u"配置raid配置文件","mkraidconf.sh",scr) def install(self): - if MakeRaid.flag: - Operation.install(self) + if ri_data.Raid.list: + return Operation.install(self) else: max = Rate.value+self.score <100 and Rate.value+self.score or 100 Rate.set(max) @@ -153,7 +151,6 @@ class Mount(Operation): """class for mount partition""" def __init__(self,scr): Operation.__init__(self,'mount partition',u'挂载分区','mount_partition.sh',scr) - self.return_value[2]=("device node doesn't exist",u"设备结点不存在") def get_stdin(self): mount='' @@ -209,6 +206,7 @@ class GenerateIssue(Operation): string = fd.read() list = string.split('\n')[0].split('-') args = ['-v']+[list[0][5:]]+["-a"]+[list[1]]+["-r"]+[list[2]]+['-d']+['-'.join(list[3:])] + fd.close() return args class ConfigureNetwork(Operation): @@ -304,4 +302,5 @@ class ConfigureBootloader(Operation): # only grub? bootloader=['-t','grub','-r',instance.device,'-k',ri_data.SerialNumber.value,'-o',list[0][5:].split('.')[0]+'.'+list[0][5:].split('.')[1]] break + fd.close() return bootloader