-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,23 @@ | |
|
||
# 用于创建数据库,请按照下面的要求填写相关的信息,再运行`python create_db.py`, | ||
# 并将生成的数据库拷贝到 blog 目录下 | ||
|
||
import os | ||
import sys | ||
import getopt | ||
import sqlite3 | ||
|
||
from miniakio.libs import crypto | ||
|
||
# 编辑下面的信息 | ||
|
||
USERNAME = "SErHo" # 用户名 | ||
EMAIL = "[email protected]" # 邮箱,登陆的时候使用 | ||
PASSWORD = "123456" # 登陆密码 | ||
DBFILE = "example/newblog.db" # 数据库名称,请保持和 blog/config.py 中设置的名称相同 | ||
USERNAME = "SErHo" # 用户名 | ||
EMAIL = "[email protected]" # 邮箱,登陆的时候使用 | ||
PASSWORD = "123456" # 登陆密码 | ||
DBFILE = "example/newblog.db" # 数据库名称,请保持和 blog/config.py 中设置的名称相同 | ||
|
||
# 请不要改动下面的内容 | ||
|
||
# 请不要改动下面的内容 | ||
|
||
def create_db(conn): | ||
c = conn.cursor() | ||
|
@@ -63,14 +65,14 @@ def get_secret(): | |
def main(argv): | ||
help = """ | ||
Usage: python tools -o <opt> | ||
opt list: | ||
createdb 创建数据库并添加用户信息(请先填写相关信息) | ||
getsecret 随机生成一个 Cookie Secret | ||
""" | ||
""" | ||
opt = "" | ||
try: | ||
opts, args = getopt.getopt(argv,"ho:",["opt="]) | ||
opts, args = getopt.getopt(argv, "ho:", ["opt="]) | ||
except getopt.GetoptError: | ||
print help | ||
sys.exit(2) | ||
|
@@ -80,7 +82,7 @@ def main(argv): | |
sys.exit() | ||
elif opt in ("-o", "--opt"): | ||
opt = arg | ||
|
||
if opt == "createdb": | ||
conn = sqlite3.connect(DBFILE) | ||
print "开始创建数据库..." | ||
|
@@ -90,7 +92,7 @@ def main(argv): | |
conn.close() | ||
print "用户创建成功,请务必将生成的数据库文件拷贝到 blogconfig 中设置的目录里!!!" | ||
elif opt == "getsecret": | ||
print get_secret() | ||
print get_secret() | ||
|
||
|
||
if __name__ == '__main__': | ||
|