|
1 | | -# -*- coding: utf-8 -*- |
2 | | - |
3 | | -import sys, \ |
4 | | - os |
5 | | -if hasattr(sys, 'frozen'): |
6 | | - os.environ['PATH'] = sys._MEIPASS + ";" + os.environ['PATH'] |
7 | | - |
8 | | -from sys import argv, exit |
9 | | -from shuClient import Ui_MainWindow |
10 | | -from wireConnect import wire_connect_status |
11 | | -from ruijie import shuConnect |
12 | | -from PyQt5.QtWidgets import QMainWindow, QApplication |
13 | | -from PyQt5.QtCore import QSettings, Qt, QTimer |
14 | | -from PyQt5.QtGui import QIcon |
15 | | -from logo_png import img as logo |
16 | | -import base64 |
17 | | -from linkSHUPath import shuPath |
18 | | - |
19 | | - |
20 | | -linkpath = shuPath() |
21 | | - |
22 | | -tmp = open(linkpath + r'\logo.png', 'wb') |
23 | | -tmp.write(base64.b64decode(logo)) |
24 | | -tmp.close() |
25 | | - |
26 | | - |
27 | | -class shuUi(QMainWindow, Ui_MainWindow): |
28 | | - def __init__(self, parent=None): |
29 | | - super(shuUi, self).__init__(parent) |
30 | | - self.setupUi(self) |
31 | | - |
32 | | - self.setWindowTitle('linkSHU') |
33 | | - self.setWindowIcon(QIcon(linkpath + r'\logo.png')) |
34 | | - |
35 | | - self.resize(391, 282) |
36 | | - self.setFixedSize(self.width(), self.height()) |
37 | | - self.setWindowFlags(Qt.WindowCloseButtonHint) |
38 | | - |
39 | | - self.input_user.setPlaceholderText("请输入用户名") |
40 | | - self.input_passwd.setPlaceholderText("请输入密码") |
41 | | - self.updateLabel.setText("<A href='https://github.com/Holaplace/shuClient'>关于 & 更新</a>") |
42 | | - self.updateLabel.setOpenExternalLinks(True) |
43 | | - |
44 | | - self.init_login_info() |
45 | | - self.wireButton.clicked.connect(self.on_pushButton_enter_clicked) |
46 | | - |
47 | | - # 自动登录 |
48 | | - self.timer0 = QTimer(self) |
49 | | - self.timer0.timeout.connect(self.goto_autologin) |
50 | | - self.timer0.setSingleShot(True) |
51 | | - self.timer0.start(1000) |
52 | | - |
53 | | - # 保存登录信息 |
54 | | - def save_login_info(self): |
55 | | - settings = QSettings(linkpath + r"\config.ini", QSettings.IniFormat) |
56 | | - settings.setValue("account", self.input_user.text()) |
57 | | - settings.setValue("password", self.input_passwd.text()) |
58 | | - settings.setValue("remeberpassword", self.passwdCB.isChecked()) |
59 | | - settings.setValue("autologin", self.auto_login.isChecked()) |
60 | | - |
61 | | - # 初始化登录信息 |
62 | | - def init_login_info(self): |
63 | | - settings = QSettings(linkpath + r"\config.ini", QSettings.IniFormat) |
64 | | - the_account =settings.value("account") |
65 | | - the_password = settings.value("password") |
66 | | - the_remeberpassword = settings.value("remeberpassword") |
67 | | - the_autologin = settings.value("autologin") |
68 | | - |
69 | | - self.input_user.setText(the_account) |
70 | | - # 记住密码判断 |
71 | | - if the_remeberpassword == "true" or the_remeberpassword is True: |
72 | | - self.passwdCB.setChecked(True) |
73 | | - self.input_passwd.setText(the_password) |
74 | | - |
75 | | - # 自动登录判断 |
76 | | - if the_autologin == "true" or the_autologin is True: |
77 | | - self.auto_login.setChecked(True) |
78 | | - |
79 | | - # 自动登录 |
80 | | - def goto_autologin(self): |
81 | | - if self.auto_login.isChecked() is True: |
82 | | - self.on_pushButton_enter_clicked() |
83 | | - |
84 | | - def on_pushButton_enter_clicked(self): |
85 | | - # 账号密码NULL判断 |
86 | | - if self.input_user.text() == "" or self.input_passwd.text() == "": |
87 | | - return |
88 | | - |
89 | | - self.auto_login.stateChanged.connect(self.cancel_autologin) |
90 | | - |
91 | | - # 保存登录信息 |
92 | | - self.save_login_info() |
93 | | - |
94 | | - self.wireConnect() |
95 | | - |
96 | | - def cancel_autologin(self): |
97 | | - if not self.auto_login.isChecked(): |
98 | | - settings = QSettings(linkpath + r"\config.ini", QSettings.IniFormat) |
99 | | - settings.setValue("autologin", False) |
100 | | - |
101 | | - def wireConnect(self): |
102 | | - # 账号密码NULL判断 |
103 | | - if self.input_user.text() == "" or self.input_passwd.text() == "": |
104 | | - return |
105 | | - |
106 | | - user = int(self.input_user.text()) |
107 | | - passwd = str(self.input_passwd.text()) |
108 | | - s = wire_connect_status(user, passwd) |
109 | | - self.status.setText(s) |
110 | | - |
111 | | - def stopConnect(self): |
112 | | - shu = shuConnect() |
113 | | - s = shu.logOut() |
114 | | - self.status.setText(s) |
115 | | - |
116 | | - |
117 | | -if __name__ == "__main__": |
118 | | - app = QApplication(argv) |
119 | | - ui = shuUi() |
120 | | - |
121 | | - ui.wireButton.clicked.connect(ui.wireConnect) |
122 | | - ui.logout.clicked.connect(ui.stopConnect) |
123 | | - |
124 | | - ui.show() |
125 | | - exit(app.exec_()) |
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +import sys, \ |
| 4 | + os |
| 5 | +if hasattr(sys, 'frozen'): |
| 6 | + os.environ['PATH'] = sys._MEIPASS + ";" + os.environ['PATH'] |
| 7 | + |
| 8 | +from sys import argv, exit |
| 9 | +from linkUI import Ui_MainWindow |
| 10 | +from wireConnect import wire_connect_status |
| 11 | +from wifiConnect import wifi_connect_status |
| 12 | +from ruijie import shuConnect |
| 13 | +from PyQt5.QtWidgets import QMainWindow, QApplication |
| 14 | +from PyQt5.QtCore import QSettings, Qt, QTimer |
| 15 | +from PyQt5.QtGui import QIcon |
| 16 | +from logo_png import img as logo |
| 17 | +from base64 import b64decode |
| 18 | +from linkSHUPath import shuPath |
| 19 | + |
| 20 | + |
| 21 | +linkpath = shuPath() |
| 22 | + |
| 23 | +sss = os.path.exists(linkpath + r'\logo.png') |
| 24 | +if not sss: |
| 25 | + tmp = open(linkpath + r'\logo.png', 'wb') |
| 26 | + tmp.write(b64decode(logo)) |
| 27 | + tmp.close() |
| 28 | +else: |
| 29 | + pass |
| 30 | + |
| 31 | + |
| 32 | +class shuUi(QMainWindow, Ui_MainWindow): |
| 33 | + def __init__(self, parent=None): |
| 34 | + super(shuUi, self).__init__(parent) |
| 35 | + self.setupUi(self) |
| 36 | + |
| 37 | + self.setWindowTitle('linkSHU (alpha)') |
| 38 | + self.setWindowIcon(QIcon(linkpath + r'\logo.png')) |
| 39 | + |
| 40 | + self.setFixedSize(self.width(), self.height()) |
| 41 | + self.setWindowFlags(Qt.WindowCloseButtonHint) |
| 42 | + |
| 43 | + self.input_user.setPlaceholderText("请输入用户名") |
| 44 | + self.input_passwd.setPlaceholderText("请输入密码") |
| 45 | + self.updateLabel.setText("<A href='https://github.com/Holaplace/shuClient'>关于 & 更新</a>") |
| 46 | + self.updateLabel.setOpenExternalLinks(True) |
| 47 | + |
| 48 | + self.init_login_info() |
| 49 | + self.login.clicked.connect(self.on_pushButton_enter_clicked) |
| 50 | + |
| 51 | + # 自动登录 |
| 52 | + self.timer0 = QTimer(self) |
| 53 | + self.timer0.timeout.connect(self.goto_autologin) |
| 54 | + self.timer0.setSingleShot(True) |
| 55 | + self.timer0.start(1000) |
| 56 | + |
| 57 | + # 保存登录信息 |
| 58 | + def save_login_info(self): |
| 59 | + settings = QSettings(linkpath + r"\config.ini", QSettings.IniFormat) |
| 60 | + settings.setValue("account", self.input_user.text()) |
| 61 | + settings.setValue("password", self.input_passwd.text()) |
| 62 | + settings.setValue("remeberpassword", self.passwdCB.isChecked()) |
| 63 | + settings.setValue("autologin", self.auto_login.isChecked()) |
| 64 | + settings.setValue("loginStyle", self.comboBox.currentIndex()) |
| 65 | + |
| 66 | + # 初始化登录信息 |
| 67 | + def init_login_info(self): |
| 68 | + settings = QSettings(linkpath + r"\config.ini", QSettings.IniFormat) |
| 69 | + the_account =settings.value("account") |
| 70 | + the_password = settings.value("password") |
| 71 | + the_remeberpassword = settings.value("remeberpassword") |
| 72 | + the_autologin = settings.value("autologin") |
| 73 | + the_loginStyle = int(settings.value("loginStyle")) |
| 74 | + |
| 75 | + self.input_user.setText(the_account) |
| 76 | + # 记住密码判断 |
| 77 | + if the_remeberpassword == "true" or the_remeberpassword is True: |
| 78 | + self.passwdCB.setChecked(True) |
| 79 | + self.input_passwd.setText(the_password) |
| 80 | + |
| 81 | + # 自动登录判断 |
| 82 | + if the_autologin == "true" or the_autologin is True: |
| 83 | + self.auto_login.setChecked(True) |
| 84 | + |
| 85 | + # 登录方式判断 |
| 86 | + if the_autologin is not int(0): |
| 87 | + self.comboBox.setCurrentIndex(the_loginStyle) |
| 88 | + |
| 89 | + # 自动登录 |
| 90 | + def goto_autologin(self): |
| 91 | + if self.auto_login.isChecked() is True: |
| 92 | + self.on_pushButton_enter_clicked() |
| 93 | + |
| 94 | + def on_pushButton_enter_clicked(self): |
| 95 | + # 账号密码NULL判断 |
| 96 | + if self.input_user.text() == "" or self.input_passwd.text() == "": |
| 97 | + return |
| 98 | + |
| 99 | + self.auto_login.stateChanged.connect(self.cancel_autologin) |
| 100 | + |
| 101 | + # 保存登录信息 |
| 102 | + self.save_login_info() |
| 103 | + self.connectStyle() |
| 104 | + |
| 105 | + def cancel_autologin(self): |
| 106 | + if not self.auto_login.isChecked(): |
| 107 | + settings = QSettings(linkpath + r"\config.ini", QSettings.IniFormat) |
| 108 | + settings.setValue("autologin", False) |
| 109 | + |
| 110 | + def connectStyle(self): |
| 111 | + try: |
| 112 | + if self.comboBox.currentIndex() is int(1): |
| 113 | + self.wireConnect() |
| 114 | + elif self.comboBox.currentIndex() is int(2): |
| 115 | + self.wifiConnect() |
| 116 | + except Exception as e: |
| 117 | + self.status.setText(e) |
| 118 | + |
| 119 | + def wireConnect(self): |
| 120 | + # 账号密码NULL判断 |
| 121 | + if self.input_user.text() == "" or self.input_passwd.text() == "": |
| 122 | + return |
| 123 | + |
| 124 | + user = int(self.input_user.text()) |
| 125 | + passwd = str(self.input_passwd.text()) |
| 126 | + s = wire_connect_status(user, passwd) |
| 127 | + self.status.setText(s) |
| 128 | + |
| 129 | + def wifiConnect(self): |
| 130 | + # 账号密码NULL判断 |
| 131 | + if self.input_user.text() == "" or self.input_passwd.text() == "": |
| 132 | + return |
| 133 | + |
| 134 | + user = int(self.input_user.text()) |
| 135 | + passwd = str(self.input_passwd.text()) |
| 136 | + |
| 137 | + s = wifi_connect_status(user, passwd) |
| 138 | + self.status.setText(s) |
| 139 | + |
| 140 | + def stopConnect(self): |
| 141 | + shu = shuConnect() |
| 142 | + s = shu.logOut() |
| 143 | + self.status.setText(s) |
| 144 | + |
| 145 | + |
| 146 | +if __name__ == "__main__": |
| 147 | + app = QApplication(argv) |
| 148 | + ui = shuUi() |
| 149 | + |
| 150 | + ui.login.clicked.connect(ui.connectStyle) |
| 151 | + ui.logout.clicked.connect(ui.stopConnect) |
| 152 | + |
| 153 | + ui.show() |
| 154 | + exit(app.exec_()) |
0 commit comments