2022-04-18 20:22:42 +08:00
|
|
|
import configparser
|
|
|
|
import platform
|
|
|
|
import os
|
2022-04-20 22:48:23 +08:00
|
|
|
from utils import BasicUtils
|
2022-04-17 22:36:19 +08:00
|
|
|
|
|
|
|
|
2022-04-18 20:22:42 +08:00
|
|
|
# todo : 用来创建软件的配置信息
|
|
|
|
class CreateConfigure:
|
|
|
|
"""
|
|
|
|
:param login_type : 登录方式 有 NextCloud、JianGuoYun、WebDav
|
|
|
|
:param webdav_login : 登录用户名
|
|
|
|
:param webdav_password : 登录密码
|
|
|
|
:param webdav_hostname : 服务地址
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, login_type, webdav_login, webdav_password, webdav_hostname=None):
|
2022-04-19 20:18:10 +08:00
|
|
|
config_file = ReturnWorkDir.return_work_dir() + 'PyQtToDoList.ini'
|
2022-04-18 20:22:42 +08:00
|
|
|
config = configparser.ConfigParser()
|
|
|
|
if not os.path.exists(config_file):
|
|
|
|
# print(config_file)
|
|
|
|
options = {}
|
|
|
|
if login_type == 'NextCloud':
|
|
|
|
webdav_hostname = webdav_hostname + '/' if webdav_hostname[-1] != '/' else webdav_hostname
|
|
|
|
options = {
|
|
|
|
'webdav_hostname': webdav_hostname + "remote.php/dav/files/admin/",
|
|
|
|
'webdav_login': webdav_login,
|
|
|
|
'webdav_password': webdav_password,
|
|
|
|
'type': login_type
|
|
|
|
}
|
|
|
|
|
|
|
|
elif login_type == 'JianGuoYun':
|
|
|
|
options = {
|
|
|
|
'webdav_hostname': "https://dav.jianguoyun.com/dav/",
|
|
|
|
'webdav_login': webdav_login,
|
|
|
|
'webdav_password': webdav_password,
|
|
|
|
'type': login_type
|
|
|
|
|
|
|
|
}
|
|
|
|
elif login_type == 'WebDav':
|
|
|
|
webdav_hostname = webdav_hostname + '/' if webdav_hostname[-1] != '/' else webdav_hostname
|
|
|
|
options = {
|
|
|
|
'webdav_hostname': webdav_hostname,
|
|
|
|
'webdav_login': webdav_login,
|
|
|
|
'webdav_password': webdav_password,
|
|
|
|
'type': login_type
|
|
|
|
|
|
|
|
}
|
|
|
|
config['Account'] = options
|
|
|
|
config['ToDoList'] = {}
|
|
|
|
|
|
|
|
with open(config_file, 'w') as f:
|
|
|
|
config.write(f)
|
|
|
|
print('create complete!', config_file)
|
|
|
|
|
2022-04-19 20:18:10 +08:00
|
|
|
# def return_config_file(self):
|
|
|
|
# if platform.system() == 'Linux':
|
|
|
|
# work_path = os.path.expandvars('$HOME') + '/.config/PyQtToDoList'
|
|
|
|
# if not os.path.exists(work_path):
|
|
|
|
# os.mkdir(work_path)
|
|
|
|
# return os.path.expandvars('$HOME') + '/.config/PyQtToDoList/PyQtToDoList.ini'
|
|
|
|
# elif platform.system() == 'Windows':
|
|
|
|
# return os.getcwd() + '/PyQtToDoList.ini'
|
2022-04-18 20:22:42 +08:00
|
|
|
|
|
|
|
|
2022-04-19 20:18:10 +08:00
|
|
|
# CreateConfigure('NextCloud', 'admin', '19990903@lyp', 'https://cloud.liyp.cc')
|