class ResponseConnect():
    def __init__(self, parent):
        self.parent = parent

        self.dw = DialogWindows(self.parent)

    def addTreeCtrl(self, storage_name, data):
        left_tree = self.parent.panes.addOSTree(storage_name, storage_name)
        root = left_tree.addRootNode(storage_name)
        for item in data:
            left_tree.addTreeNodes(root, item['Name'])
        self.parent.panes.show([storage_name])

    def check_value(self, data):
        for key in data.keys():
            if not data[key]:
                self.dw.error_message('数据仓库', '%s不能为空' % key)
                return False
            data[key].encode('utf-8')

        return True

    def _connect_aliyun(self, data):
        if self.check_value(data):
            self.parent.aliyun = Aliyun(data['website'], data['id'],
                                        data['key'])
            buckets = self.parent.aliyun.get_all_buckets()
            self.addTreeCtrl('阿里云', buckets)

    def OnConnectAliyun(self, event):
        # 设置为对象存储
        self.parent.flag = wx.ID_NO
        dialog = ConnectDialog(self.parent, '连接阿里云存储')
        if dialog.ShowModal() == wx.ID_OK:
            data = dialog.getValue()
            data = {
                'website': 'oss.aliyuncs.com',
                'id': 'HB50JO83yRE8KhLG',
                'key': '3fAiGQ4Cu4tDeq9rCXG72P1ITcInJa'
            }
            self._connect_aliyun(data)
        dialog.Destroy()

    def OnConnectS3(self, event):
        pass

    def OnConnectSwift(self, event):
        pass
Пример #2
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          '数据仓库',
                          size=(1024, 600),
                          pos=(50, 0))

        self.dlg = DialogWindows(self)

        # 设置默认为数据仓库
        self.flag = wx.ID_OK

        # 设置配置文件路径
        self.configfile = './dmanage/config.txt'

        self.initFrame()
        self.initConfig()
class ResponseConnect:
    def __init__(self, parent):
        self.parent = parent

        self.dw = DialogWindows(self.parent)

    def addTreeCtrl(self, storage_name, data):
        left_tree = self.parent.panes.addOSTree(storage_name, storage_name)
        root = left_tree.addRootNode(storage_name)
        for item in data:
            left_tree.addTreeNodes(root, item["Name"])
        self.parent.panes.show([storage_name])

    def check_value(self, data):
        for key in data.keys():
            if not data[key]:
                self.dw.error_message("数据仓库", "%s不能为空" % key)
                return False
            data[key].encode("utf-8")

        return True

    def _connect_aliyun(self, data):
        if self.check_value(data):
            self.parent.aliyun = Aliyun(data["website"], data["id"], data["key"])
            buckets = self.parent.aliyun.get_all_buckets()
            self.addTreeCtrl("阿里云", buckets)

    def OnConnectAliyun(self, event):
        # 设置为对象存储
        self.parent.flag = wx.ID_NO
        dialog = ConnectDialog(self.parent, "连接阿里云存储")
        if dialog.ShowModal() == wx.ID_OK:
            data = dialog.getValue()
            data = {"website": "oss.aliyuncs.com", "id": "HB50JO83yRE8KhLG", "key": "3fAiGQ4Cu4tDeq9rCXG72P1ITcInJa"}
            self._connect_aliyun(data)
        dialog.Destroy()

    def OnConnectS3(self, event):
        pass

    def OnConnectSwift(self, event):
        pass
Пример #4
0
    def __init__(self):
        wx.Frame.__init__(self, None, -1,
                          '数据仓库',
                          size=(1024, 600),
                          pos=(50, 0))

        self.dlg = DialogWindows(self)

        # 设置默认为数据仓库
        self.flag = wx.ID_OK

        # 设置配置文件路径
        self.configfile = './dmanage/config.txt'

        self.initFrame()
        self.initConfig()
    def __init__(self, parent):
        self.parent = parent

        self.dw = DialogWindows(self.parent)
Пример #6
0
 def __init__(self, parent):
     self.parent = parent
     self.dlg = DialogWindows(self.parent)
     self.printer = PrintWork(self.parent)
Пример #7
0
class ResponseFile():

    def __init__(self, parent):
        self.parent = parent
        self.dlg = DialogWindows(self.parent)
        self.printer = PrintWork(self.parent)

    def _show_data_storage(self, path, flag=DS_CREATE):
        storage_name = os.path.basename(path)
        self.parent.cf_tree = self.parent.panes.addCFTree(storage_name,
                                                          storage_name,
                                                          path)
        update_option(self.parent.configfile,
                      'path', 'cf_defalt_path', path)

    def _create_data_storage(self, path):
        cf = ComplexFile()
        cf.createCF(path)
        self._show_data_storage(path)

    # 新建数据仓库
    def OnNew(self, event):
        dlg = wx.FileDialog(self.parent,
                            "新建数据仓库",
                            wildcard=wildcard,
                            style=wx.SAVE)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath().encode('utf-8')
            if path:
                self._create_data_storage(path)
        dlg.Destroy()
        #path = "D://mydatabase/datastorage/test.xml"
        # self._show_data_storage(path)

    # 打开数据仓库
    def OnOpen(self, event):
        dlg = wx.FileDialog(self.parent,
                            "打开数据仓库",
                            wildcard=wildcard,
                            style=wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            if path:
                self._show_data_storage(path, DS_OPEN)
        dlg.Destroy()

#         path = "D://mydatabase/datastorage/test.xml"
#         self._show_data_storage(path, DS_OPEN)

    # 保存更改到数据仓库
    def OnSave(self, event):
        print '保存数据仓库'

    # 保存所有的更改到数据仓库
    def OnSaveAll(self, event):
        cf_tree = self.parent.getCFTreeHandle()
        cf_tree.saveToFile()

    # 关闭当前的数据仓库
    def OnClose(self, event):
        notebook = self.parent.getNotebookHandle()
        current_page = notebook.GetCurrentPage()
        if current_page is not None:
            page_idx = notebook.GetPageIndex(current_page)
            notebook.DeletePage(page_idx)

    # 关闭全部打开的数据仓库
    def OnCloseAll(self, event):
        print 'OnOpen'

    # 打印设置
    def OnSetPrinter(self, event):
        self.printer.printSetup()

    # 打印预览
    def OnPrinterPreview(self, event):
        import os
        filename = os.path.join(os.path.dirname(__file__), 'sample.txt')
        text = open(filename).read()
        result = self.printer.printPreview(text)
        if not result:
            self.dlg.error_message('打印预览', '打印预览失败!')

    # 打印
    def OnPrinter(self, event):
        text = 'hello'
        self.printer.printing(text)

    # 退出窗口
    def OnCloseWindow(self, event):
        self.parent.Close()
Пример #8
0
class DataStorageFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          '数据仓库',
                          size=(1024, 600),
                          pos=(50, 0))

        self.dlg = DialogWindows(self)

        # 设置默认为数据仓库
        self.flag = wx.ID_OK

        # 设置配置文件路径
        self.configfile = './dmanage/config.txt'

        self.initFrame()
        self.initConfig()

    # 初始化窗口
    def initFrame(self):
        # 设置窗口最小值
        self.SetMinSize(wx.Size(400, 300))
        # 初始化各个部件
        self.initMenuBar()
        self.initStatusBar()
        self.initPanes()
        self.initObjectStorage()

    # 初始化标题栏
    def initMenuBar(self):
        self.menu = CreateMenu(self)

    # 初始化状态栏
    def initStatusBar(self):
        self.statusbar = self.CreateStatusBar()
        self.statusbar.SetFieldsCount(3)
        self.statusbar.SetStatusWidths([-2, -2, -1])

    # 初始化工具栏
    def initToolBar(self):
        pass
        # self.toolbar = CreateToolBar(self)

    # 初始化中心窗口的部件
    def initPanes(self):
        self.panes = CreatePanes(self)
        #self.notebook = self.panes.addRighNotebook('notebook')
        self.richtext = self.panes.addRichText('richtext')
        self.tb1 = self.panes.addToolBar('tb1')
        self.cf_tree = None
        self.os_tree = None

    def initObjectStorage(self):
        self.aliyun = None
        self.s3 = None
        self.swift = None

    def configData(self):
        return {
            'path': {
                'cf_defalt_path': '',
                'cf_defalt': ''
            },
            'displayjson': {
                'colour': '',
                'indent': ''
            }
        }

    def initConfig(self):
        if not os.path.exists(self.configfile):
            create_configfile(self.configfile, self.configData())

    def bindEvent(self):
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUi)

    def getPaneHandle(self):
        return self.panes

    def getCFTreeHandle(self):
        return self.panes.left_cf_tree

    def getOSTreeHandle(self):
        return self.panes.left_os_tree

    def getNotebookHandle(self):
        return self.notebook

    def getToolbarHandle(self):
        return self.tb1

    def OnClose(self, event):
        content = '以下数据仓库已经做修改, 是否保存修改到数据仓库?'
        result = self.dlg.question_message('数据仓库', content, wx.CANCEL)
        if result == wx.ID_NO:
            self.Destroy()
        elif result == wx.ID_YES:
            print '保存数据'
            self.Destroy()

    def OnUpdateUi(self, event):
        print 'Update ui'
Пример #9
0
class DataStorageFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, -1,
                          '数据仓库',
                          size=(1024, 600),
                          pos=(50, 0))

        self.dlg = DialogWindows(self)

        # 设置默认为数据仓库
        self.flag = wx.ID_OK

        # 设置配置文件路径
        self.configfile = './dmanage/config.txt'

        self.initFrame()
        self.initConfig()

    # 初始化窗口
    def initFrame(self):
        # 设置窗口最小值
        self.SetMinSize(wx.Size(400, 300))
        # 初始化各个部件
        self.initMenuBar()
        self.initStatusBar()
        self.initPanes()
        self.initObjectStorage()

    # 初始化标题栏
    def initMenuBar(self):
        self.menu = CreateMenu(self)

    # 初始化状态栏
    def initStatusBar(self):
        self.statusbar = self.CreateStatusBar()
        self.statusbar.SetFieldsCount(3)
        self.statusbar.SetStatusWidths([-2, -2, -1])

    # 初始化工具栏
    def initToolBar(self):
        pass
        # self.toolbar = CreateToolBar(self)

    # 初始化中心窗口的部件
    def initPanes(self):
        self.panes = CreatePanes(self)
        #self.notebook = self.panes.addRighNotebook('notebook')
        self.richtext = self.panes.addRichText('richtext')
        self.tb1 = self.panes.addToolBar('tb1')
        self.cf_tree = None
        self.os_tree = None

    def initObjectStorage(self):
        self.aliyun = None
        self.s3 = None
        self.swift = None

    def configData(self):
        return {'path': {
            'cf_defalt_path': '',
            'cf_defalt': ''},
            'displayjson': {
            'colour': '',
            'indent': ''}
        }

    def initConfig(self):
        if not os.path.exists(self.configfile):
            create_configfile(self.configfile, self.configData())

    def bindEvent(self):
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUi)

    def getPaneHandle(self):
        return self.panes

    def getCFTreeHandle(self):
        return self.panes.left_cf_tree

    def getOSTreeHandle(self):
        return self.panes.left_os_tree

    def getNotebookHandle(self):
        return self.notebook

    def getToolbarHandle(self):
        return self.tb1

    def OnClose(self, event):
        content = '以下数据仓库已经做修改, 是否保存修改到数据仓库?'
        result = self.dlg.question_message('数据仓库', content, wx.CANCEL)
        if result == wx.ID_NO:
            self.Destroy()
        elif result == wx.ID_YES:
            print '保存数据'
            self.Destroy()

    def OnUpdateUi(self, event):
        print 'Update ui'
    def __init__(self, parent):
        self.parent = parent

        self.dw = DialogWindows(self.parent)
Пример #11
0
 def __init__(self, parent):
     self.parent = parent
     self.dlg = DialogWindows(self.parent)
     self.printer = PrintWork(self.parent)
Пример #12
0
class ResponseFile():
    def __init__(self, parent):
        self.parent = parent
        self.dlg = DialogWindows(self.parent)
        self.printer = PrintWork(self.parent)

    def _show_data_storage(self, path, flag=DS_CREATE):
        storage_name = os.path.basename(path)
        self.parent.cf_tree = self.parent.panes.addCFTree(
            storage_name, storage_name, path)
        update_option(self.parent.configfile, 'path', 'cf_defalt_path', path)

    def _create_data_storage(self, path):
        cf = ComplexFile()
        cf.createCF(path)
        self._show_data_storage(path)

    # 新建数据仓库
    def OnNew(self, event):
        dlg = wx.FileDialog(self.parent,
                            "新建数据仓库",
                            wildcard=wildcard,
                            style=wx.SAVE)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath().encode('utf-8')
            if path:
                self._create_data_storage(path)
        dlg.Destroy()
        #path = "D://mydatabase/datastorage/test.xml"
        # self._show_data_storage(path)

    # 打开数据仓库
    def OnOpen(self, event):
        dlg = wx.FileDialog(self.parent,
                            "打开数据仓库",
                            wildcard=wildcard,
                            style=wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            if path:
                self._show_data_storage(path, DS_OPEN)
        dlg.Destroy()


#         path = "D://mydatabase/datastorage/test.xml"
#         self._show_data_storage(path, DS_OPEN)

# 保存更改到数据仓库

    def OnSave(self, event):
        print '保存数据仓库'

    # 保存所有的更改到数据仓库
    def OnSaveAll(self, event):
        cf_tree = self.parent.getCFTreeHandle()
        cf_tree.saveToFile()

    # 关闭当前的数据仓库
    def OnClose(self, event):
        notebook = self.parent.getNotebookHandle()
        current_page = notebook.GetCurrentPage()
        if current_page is not None:
            page_idx = notebook.GetPageIndex(current_page)
            notebook.DeletePage(page_idx)

    # 关闭全部打开的数据仓库
    def OnCloseAll(self, event):
        print 'OnOpen'

    # 打印设置
    def OnSetPrinter(self, event):
        self.printer.printSetup()

    # 打印预览
    def OnPrinterPreview(self, event):
        import os
        filename = os.path.join(os.path.dirname(__file__), 'sample.txt')
        text = open(filename).read()
        result = self.printer.printPreview(text)
        if not result:
            self.dlg.error_message('打印预览', '打印预览失败!')

    # 打印
    def OnPrinter(self, event):
        text = 'hello'
        self.printer.printing(text)

    # 退出窗口
    def OnCloseWindow(self, event):
        self.parent.Close()