pigrow_remote.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:Pigrow 作者: Pragmatismo 项目源码 文件源码
def update_setting_click(self, e):
        #create updated settings file
        #
        #creating GPIO config block
        item_count = config_info_pnl.gpio_table.GetItemCount()
        # add dht22 sesnsor if present;
        if "dht22sensor" in self.gpio_dict:
            gpio_config_block = "\ngpio_dht22sensor=" + self.gpio_dict["dht22sensor"]
        else:
            gpio_config_block = ""
        # list all devices with gpio and wiring directions
        for count in range(0, item_count):
            device = config_info_pnl.gpio_table.GetItem(count, 0).GetText()
            gpio = config_info_pnl.gpio_table.GetItem(count, 1).GetText()
            wiring = config_info_pnl.gpio_table.GetItem(count, 2).GetText()
            gpio_config_block += "\ngpio_" + device + "=" + gpio
            gpio_config_block += "\ngpio_" + device + "_on=" + wiring
        # list all non-gpio settings
        other_settings = ""
        for key, value in self.config_dict.items():
            other_settings += "\n" + key + "=" + value
        config_text = other_settings[1:]
        config_text += gpio_config_block
        # show user and ask user if they relly want to update
        dbox = wx.MessageDialog(self, config_text, "upload to pigrow?", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
        answer = dbox.ShowModal()
        dbox.Destroy()
        #if user said ok then upload file to pi
        if (answer == wx.ID_OK):
            #
            # REPLACE THE FOLLOWING WITH A FUNCTION THAT ANYONE CAN CALL TO UPLOAD A FILE
            #
            sftp = ssh.open_sftp()
            folder = "/home/" + str(pi_link_pnl.target_user) +  "/Pigrow/config/"
            f = sftp.open(folder + '/pigrow_config.txt', 'w')
            f.write(config_text)
            f.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号