1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 from __future__ import print_function
28 import os, sys, re, ConfigParser, getpass, base64
29
30 dirNm, execName = os.path.split(sys.argv[0])
31 sys.path.insert(1,os.path.abspath(os.path.join(dirNm, "../libexec")))
32 sys.path.insert(1,os.path.realpath(os.path.join(dirNm, "../site")))
33
34 import argparse
35
39
41 parser = argparse.ArgumentParser()
42 parser.add_argument("--dbhost", dest='dbhost', action="store", help="db host")
43 parser.add_argument("--dbuser", dest='dbuser', action="store", help="db user")
44 parser.add_argument("--passwd", dest='passwd', action="store", help="password")
45 parser.add_argument("--dbname", dest='dbname', action="store", help="name of db")
46
47 args = parser.parse_args()
48
49 return args
52 self.__host = args.dbhost
53 self.__user = args.dbuser
54 self.__passwd = args.passwd
55 self.__db = args.dbname
56
58 if (not self.__host): self.__host = raw_input("Database host: ")
59 if (not self.__user): self.__user = raw_input("Database user: ")
60 if (not self.__passwd): self.__passwd = getpass.getpass("Database pass: ")
61 if (not self.__db): self.__db = raw_input("Database name: ")
62
64 config=ConfigParser.ConfigParser()
65 config.add_section("MYSQL")
66 config.set("MYSQL","HOST",self.__host)
67 config.set("MYSQL","USER",self.__user)
68 config.set("MYSQL","PASSWD",base64.b64encode(self.__passwd))
69 config.set("MYSQL","DB",self.__db)
70
71 fn = self.__db + "_db.conf"
72
73 f = open(fn,"w")
74 config.write(f)
75 f.close()
76
81
82
83
85 args = CmdLineOptions().execute()
86 createConf = CreateConf(args)
87 createConf.create()
88
89
90 if ( __name__ == '__main__'): main()
91