Files
new_install/interface/check_oldconf.py

71 lines
1.9 KiB
Python

#!/usr/bin/python
#! coding: utf-8
''' file check_oldconf.py
Decide whether to delete the install.xml file'''
import Tkinter
import sys
import subprocess
import getopt
ins_xml = '/var/install/install.xml'
lang = 'english'
message = {}
message['english'] = 'The system detects the presence of the last\n \
installation to retain the configuration file, whether to use'
message['chinese'] = '系统检测到存在上次安装保留的配置文件,是否使用它'
def print_usages():
print 'Usage: %s [-l|--language language] [-h|--help]' % sys.argv[0]
print 'language [english|chinese]'
print 'default language is english'
def yes():
root.destroy()
def no():
''' remove system left install.xml file'''
cmd='rm -rf ' + ins_xml
subprocess.Popen(cmd,shell=True)
root.destroy()
def init(language):
''' implement Widget'''
global root
root = Tkinter.Tk()
root.title("Linx")
root.geometry("%sx%s+0+0" % (root.winfo_screenwidth(),
root.winfo_screenheight()))
txt = message[language]
lab = Tkinter.Label(root,text=txt)
lab.grid(row=1,column=1)
btn1 = Tkinter.Button(root,text='Yes',command=sys.modules[__name__].yes)
btn2 = Tkinter.Button(root,text='No',command=sys.modules[__name__].no)
btn1.grid(row=2,column=0,padx=40,pady=100,ipadx=20)
btn2.grid(row=2,column=2,padx=20,pady=100,ipadx=15)
root.rowconfigure(1,weight=2)
root.columnconfigure(1,weight=1)
root.rowconfigure(2,weight=1)
root.mainloop()
try:
opts,args = getopt.getopt(sys.argv[1:],"l:",["language="])
except getopt.GetoptError:
print_usages()
sys.exit(1)
for opt,arg in opts:
if opt in ('-l','--language'):
lang = arg
if opt in ('-h','--help'):
print_usages()
sys.exit(0)
if lang in ('english','chinese'):
init(lang)
else:
print_usages()
sys.exit(1)