Exemplo n.º 1
0
 def test_02_export_channels(self):
 
     Import_Export_Test.exported_data = get_data()
     
     monitor_channel = Channel(Import_Export_Test.exported_data["monitor"])
     
     test_category = Category("test")
     test_category.add("monitor",monitor_channel)
     
     Import_Export_Test.exported_data["monitor1"] = get_data()["monitor"]
     test_category.add("monitor1",monitor_channel)
     
     exporter  = JSON_Exporter()
     exporter.to_JSON(path,test_category.get_channels(),Channel_Encoder)
     print("\n")
     _print_("exporting channels to json file = " 
            + path 
            + "\n"
            +json.dumps(Import_Export_Test.exported_data
            ,indent = 4 , cls = Channel_Encoder))
     
     size = file_util.file_size(path)
     self.assertNotEqual(0,size)
     
     print("----------------------------------------------------------------------")
Exemplo n.º 2
0
 def save_app_state(self):
     """
     App state saved.
     
     The channels in the default category is exported to a JSON File.
     This file is used to restore channels which have been there in the app
     while it was closed.
     """
     exporter = JSON_Exporter()
     path = file_util.find_file(__file__, "../data/channels/saved_channels")
     if path != '':
         exporter.to_JSON(path, Channel_Store.ALL.get_channels(),
                          Channel_Encoder)
    def _export(self, widget, data=None):
        """
        Create A JSON Exporter.

        Get the file path from the TextField in Export Box.

        Export channel data to specified path.
        """

        exporter = JSON_Exporter()
        path = self.box.text_entry.get_text()
        if path != '':
            exporter.to_JSON(path, Channel_Store.ALL.get_channels(),
                             Channel_Encoder)
            self.box.export_box.destroy()
Exemplo n.º 4
0
 def save_app_state(self):
     
     """
     App state saved.
     
     The channels in the default category is exported to a JSON File.
     This file is used to restore channels which have been there in the app
     while it was closed.
     """
     exporter  = JSON_Exporter()
     path = file_util.find_file(__file__,
                                "../data/channels/saved_channels")
     if path != '':
         exporter.to_JSON(path
                         ,Channel_Store.ALL.get_channels()
                         ,Channel_Encoder)
Exemplo n.º 5
0
    def _export(self,widget,data=None):

        """
        Create A JSON Exporter.

        Get the file path from the TextField in Export Box.

        Export channel data to specified path.
        """

        exporter  = JSON_Exporter()
        path = self.box.text_entry.get_text()
        if path != '':
            exporter.to_JSON(path
                            ,Channel_Store.ALL.get_channels()
                            ,Channel_Encoder)
            self.box.export_box.destroy()
Exemplo n.º 6
0
    def export_sample_monitor(self):
        """
       Exports  a monitor channel runinng on local machine. For that first we
       get monitor channel configuration data from channel store.
       After that the monitor data is exported to file in JSON format using
       JSON Exporter and Channel Encoder.
       """

        ## Data to export
        exported_data = channel_store.get_monitor_data()

        ## monitor channel
        monitor_channel = Channel(exported_data["monitor"])

        ## path where channel data is exported.
        path = file_util.find_file(
            __file__, "../data/channels/to_import_sample_data.p2psp")

        ## JSON Exporter
        exporter = JSON_Exporter()
        exporter.to_JSON(path, {"monitor": monitor_channel}, Channel_Encoder)
Exemplo n.º 7
0
    def export_sample_monitor(self):

       """
       Exports  a monitor channel runinng on local machine. For that first we
       get monitor channel configuration data from channel store.
       After that the monitor data is exported to file in JSON format using
       JSON Exporter and Channel Encoder.
       """

       ## Data to export
       exported_data = channel_store.get_monitor_data()

       ## monitor channel
       monitor_channel = Channel(exported_data["monitor"])

       ## path where channel data is exported.
       path = file_util.find_file(__file__,
                                   "../data/channels/to_import_sample_data.p2psp")

       ## JSON Exporter
       exporter  = JSON_Exporter()
       exporter.to_JSON(path,{"monitor":monitor_channel},Channel_Encoder)