Added ability to send configuration files from server
This commit is contained in:
Artem30801
2019-03-20 16:26:01 +03:00
parent 51370fb7a0
commit a5d6d2e610
2 changed files with 22 additions and 4 deletions

View File

@@ -254,6 +254,10 @@ try:
print("Command from server:", command, args)
if command == "writefile":
recive_file(list(args.values)[0])
elif command == 'config_write':
write_to_config(args['section'], args['option'], args['value'])
elif command == 'config_reload':
load_config()
elif command == "starttime":
starttime = float(list(args.values)[0])
print("Starting on:", time.ctime(starttime))
@@ -279,7 +283,7 @@ try:
print("Got request for:", request_target)
response = ""
if request_target == 'test':
response = "test_succsess"
response = "test_success"
elif request_target == 'id':
response = COPTER_ID
elif request_target == 'selfcheck':

View File

@@ -270,6 +270,7 @@ class MainWindow(QtWidgets.QMainWindow):
self.ui.disarm_button.clicked.connect(self.disarm_all)
self.ui.action_send_animations.triggered.connect(self.send_animations)
self.ui.action_send_configurations.triggered.connect(self.send_configurations)
#Initing table and table model
self.ui.tableView.setModel(model)
@@ -330,9 +331,22 @@ class MainWindow(QtWidgets.QMainWindow):
copter.send_file(file, "animation.csv") # TODO config
else:
print("Filename not matches with any drone connected")
# dr = next(iter(Client.clients.values())) # костыль для тестирования
# ANS = dr.get_response("someshit")
# print(ANS)
@pyqtSlot()
def send_configurations(self):
path = QFileDialog.getOpenFileName(self, "Select configuration file", filter="Configs (*.ini *.txt .cfg)")[0]
if path:
print("Selected file:", path)
sendable_config = configparser.ConfigParser()
sendable_config.read(path)
for section in sendable_config.sections():
for option in dict(sendable_config.items(section)):
value = sendable_config[section][option]
print("Got item from config:", section, option, value)
Client.send_to_selected(
Client.form_message('config_write', {'section': section, 'option': option, 'value': value})
)
Client.send_to_selected(Client.form_message("config_reload"))
model = QStandardItemModel()