示例#1
0
 def __init__(self):
     self.__data = PontonData()
     wx.Frame.__init__(self, None, title=u'Develop ' + \
                       self.__data.get_('pontonguititle'),
                       size=(500, 500))
     self.__test = PontonTest()
     self.__find = PontonFind(self, self.__data)
     self.__tool = PontonGUItools(self, self.__data, self.__test,
                                  self.__find)
     self.__ldic = {'existcfg': 'PontonFind.search_exist_cfg()',
                    'existinst': 'PontonFind.search_exist_inst()',
                    'searchdir': 'PontonFind.search_app_dir()',
                    'removedir': 'PontonFind.remove_app_dir()',
                    'gui': 'PontonGUI()',
                    'instproc': 'PontonInstProcDlg(data, test, ' + \
                                'tool, /home/tygrys/LORZEtesting)',
                    'makexe': 'PontonGUItools.make_exec(' + \
                              '/home/tygrys/LORZEtesting)',
                    'pytopyw': 'PontonGUItools.ren_py_pyw(' + \
                               '/home/tygrys/LORZEtesting)',
                    'makeuninst': 'PontonGUItools.make_uninst(' + \
                                  '/home/tygrys/LORZEtesting)',
                    'readuninst': 'PontonGUItools.read_uninst(' + \
                                  '/home/tygrys/LORZEtesting)',
                    'removeapp': 'PontonGUItools.remove_app(' + \
                                 '/home/tygrys/LORZEtesting, 0.2)',
                    'instdlg': 'PontonInstDlg(data, find)',
                    'listdlg': 'PontonListDlg(data, title, ' + \
                               'choicelist, default)',
                    'startdlg': 'PontonStarterDlg(data, test, ' + \
                                '/home/tygrys)',
                    'srcdir': 'PontonGUItools.read_src_dir()',
                    'srclist': 'PontonGUItools.get_src_list()',
                    'srcinst': 'PontonGUItools.install_src(' + \
                               '"/home/tygrys/LORZEtesting")',
                    'makestartscript': 'PontonGUItools.' + \
                                       'make_start_bash(' + \
                                       '/home/tygrys/LORZEtesting)'}
     self.__testing = []
     for i in ('existcfg',
               'existinst',
               'searchdir',
               'removedir',
               'gui',
               'instdlg',
               'listdlg',
               'srcdir',
               'srclist',
               'srcinst',
               'pytopyw',
               'makestartscript',
               'makeuninst',
               'makexe',
               'startdlg',
               'readuninst',
               'instproc',
               'removeapp'):
         self.__testing.append(self.__ldic[i])
     # srcdir.txt
     self.set_write_srcdir()
     # listbox
     self.__list = wx.ListBox(self, size=(-1, -1),
                              choices=self.__testing)
     self.__list.SetSelection(0)
     buttonexit = wx.Button(self, label=u'Exit')
     # bindings
     buttonexit.Bind(wx.EVT_BUTTON, self.on_exit)
     self.__list.Bind(wx.EVT_LISTBOX_DCLICK, self.on_list)
     self.__list.Bind(wx.EVT_KEY_DOWN, self.on_key_down)
     # layout
     vbox = wx.BoxSizer(wx.VERTICAL)
     vbox.Add(self.__list, 1, wx.EXPAND | wx.ALL, 5)
     vbox.Add(buttonexit, 0, wx.EXPAND | wx.ALL, 5)
     self.__list.SetFocus()
     self.SetSizer(vbox)
     self.Centre()
     self.Show()
示例#2
0
class Testing(wx.Frame):
    '''Testing()
       object for testing

    exit_frame()
    Close program.

    get_selection()
    Run selected entry in the list.

    on_exit(event)
    Event, exit button.

    on_key_down(event)
    Event, key is pressed.'

    on_list(event)
    Event, doubleclick on list.

    set_write_srcdir()
    Set and write 'srcdir.txt' for testing.

    '''

    def __init__(self):
        self.__data = PontonData()
        wx.Frame.__init__(self, None, title=u'Develop ' + \
                          self.__data.get_('pontonguititle'),
                          size=(500, 500))
        self.__test = PontonTest()
        self.__find = PontonFind(self, self.__data)
        self.__tool = PontonGUItools(self, self.__data, self.__test,
                                     self.__find)
        self.__ldic = {'existcfg': 'PontonFind.search_exist_cfg()',
                       'existinst': 'PontonFind.search_exist_inst()',
                       'searchdir': 'PontonFind.search_app_dir()',
                       'removedir': 'PontonFind.remove_app_dir()',
                       'gui': 'PontonGUI()',
                       'instproc': 'PontonInstProcDlg(data, test, ' + \
                                   'tool, /home/tygrys/LORZEtesting)',
                       'makexe': 'PontonGUItools.make_exec(' + \
                                 '/home/tygrys/LORZEtesting)',
                       'pytopyw': 'PontonGUItools.ren_py_pyw(' + \
                                  '/home/tygrys/LORZEtesting)',
                       'makeuninst': 'PontonGUItools.make_uninst(' + \
                                     '/home/tygrys/LORZEtesting)',
                       'readuninst': 'PontonGUItools.read_uninst(' + \
                                     '/home/tygrys/LORZEtesting)',
                       'removeapp': 'PontonGUItools.remove_app(' + \
                                    '/home/tygrys/LORZEtesting, 0.2)',
                       'instdlg': 'PontonInstDlg(data, find)',
                       'listdlg': 'PontonListDlg(data, title, ' + \
                                  'choicelist, default)',
                       'startdlg': 'PontonStarterDlg(data, test, ' + \
                                   '/home/tygrys)',
                       'srcdir': 'PontonGUItools.read_src_dir()',
                       'srclist': 'PontonGUItools.get_src_list()',
                       'srcinst': 'PontonGUItools.install_src(' + \
                                  '"/home/tygrys/LORZEtesting")',
                       'makestartscript': 'PontonGUItools.' + \
                                          'make_start_bash(' + \
                                          '/home/tygrys/LORZEtesting)'}
        self.__testing = []
        for i in ('existcfg',
                  'existinst',
                  'searchdir',
                  'removedir',
                  'gui',
                  'instdlg',
                  'listdlg',
                  'srcdir',
                  'srclist',
                  'srcinst',
                  'pytopyw',
                  'makestartscript',
                  'makeuninst',
                  'makexe',
                  'startdlg',
                  'readuninst',
                  'instproc',
                  'removeapp'):
            self.__testing.append(self.__ldic[i])
        # srcdir.txt
        self.set_write_srcdir()
        # listbox
        self.__list = wx.ListBox(self, size=(-1, -1),
                                 choices=self.__testing)
        self.__list.SetSelection(0)
        buttonexit = wx.Button(self, label=u'Exit')
        # bindings
        buttonexit.Bind(wx.EVT_BUTTON, self.on_exit)
        self.__list.Bind(wx.EVT_LISTBOX_DCLICK, self.on_list)
        self.__list.Bind(wx.EVT_KEY_DOWN, self.on_key_down)
        # layout
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.__list, 1, wx.EXPAND | wx.ALL, 5)
        vbox.Add(buttonexit, 0, wx.EXPAND | wx.ALL, 5)
        self.__list.SetFocus()
        self.SetSizer(vbox)
        self.Centre()
        self.Show()

    def on_exit(self, event):
        '''Event, exit button.'''
        self.exit_frame()

    def on_list(self, event):
        '''Event, doubleclick on list.'''
        self.get_selection()

    def on_key_down(self, event):
        '''Event, key is pressed.'''
        if event.GetKeyCode() == wx.WXK_ESCAPE:
            self.exit_frame()
        elif event.GetKeyCode() == wx.WXK_RETURN:
            self.get_selection()
        elif event.GetKeyCode() == wx.WXK_NUMPAD_ENTER:
            self.get_selection()

    def exit_frame(self):
        '''Close program.'''
        self.Close()

    def get_selection(self):
        '''Run selected entry in the list.'''
        cmd = self.__testing[self.__list.GetSelection()]
        if cmd == self.__ldic['existcfg']:
            dic = self.__find.search_exist_cfg()
            text = 'dictionairy\n'
            for key, value in dic.items():
                text = text + key + ' : ' + value + '\n'
            dlg = wx.MessageDialog(self, text, cmd, style=wx.OK)
            dlg.ShowModal()
        elif cmd == self.__ldic['existinst']:
            dic = self.__find.search_exist_inst()
            text = 'dictionairy\n'
            for key, value in dic.items():
                text = text + key + ' : ' + value + '\n'
            dlg = wx.MessageDialog(self, text, cmd, style=wx.OK)
            dlg.ShowModal()
        elif cmd == self.__ldic['searchdir']:
            dirlist = self.__find.search_app_dir()
            text = 'list\n'
            for i in dirlist:
                text = text + i + '\n'
            dlg = wx.MessageDialog(self, text, cmd, style=wx.OK)
            dlg.ShowModal()
        elif cmd == self.__ldic['removedir']:
            text = 'removing "foo": '
            text = text + str(self.__find.remove_app_dir('foo',
                                                       '0.2')) + '\n'
            text = text + 'removing "~/Dropbox/Andy/ERASAND/LORZE": '
            text = text + str(self.__find.remove_app_dir(\
                          '~/Dropbox/Andy/ERASAND/LORZE', '0.2')) + '\n'
            dlg = wx.MessageDialog(self, text, cmd, style=wx.OK)
            dlg.ShowModal()
        elif cmd == self.__ldic['pytopyw']:
            text = self.__tool.ren_py_pyw('/home/tygrys/LORZEtesting')
            dlg = PontonTextDlg(self, self.__data, cmd, text)
            dlg.ShowModal()
            dlg.Destroy()
        elif cmd == self.__ldic['makexe']:
            text = self.__tool.make_exec('/home/tygrys/LORZEtesting')
            dlg = PontonTextDlg(self, self.__data, cmd, text)
            dlg.ShowModal()
            dlg.Destroy()
        elif cmd == self.__ldic['makeuninst']:
            text = self.__tool.make_uninst('/home/tygrys/LORZEtesting')
            dlg = PontonTextDlg(self, self.__data, cmd, text)
            dlg.ShowModal()
            dlg.Destroy()
        elif cmd == self.__ldic['readuninst']:
            dirlist, filelist = self.__tool.read_uninst(\
                               '/home/tygrys/LORZEtesting')
            text = 'DIRLIST\n'
            for i in dirlist:
                text = text + i + '\n'
            text = text + '\nFILELIST\n'
            for i in filelist:
                text = text + i + '\n'
            dlg = PontonTextDlg(self, self.__data, cmd, text)
            dlg.ShowModal()
            dlg.Destroy()
        elif cmd == self.__ldic['removeapp']:
            self.__tool.remove_app('/home/tygrys/LORZEtesting', '0.2')
        elif cmd == self.__ldic['instdlg']:
            dlg = PontonInstDlg(self, self.__data, self.__find,
                                self.__tool)
            dlg.ShowModal()
            appdir = dlg.get_app_dir()
            dlg.Destroy()
            print(appdir)
        elif cmd == self.__ldic['gui']:
            PontonGUI()
        elif cmd == self.__ldic['listdlg']:
            _dir = os.getcwd()
            choicelist = []
            choicelist.append(_dir[:len(_dir) - 8])
            choicelist.append('./test1')
            choicelist.append('./apps/test2')
            dlg = PontonListDlg(self, self.__data, cmd, choicelist,
                                choicelist[0])
            dlg.ShowModal()
            appdir = dlg.get_choice()
            dlg.Destroy()
            print(appdir)
        elif cmd == self.__ldic['startdlg']:
            dlg = PontonStarterDlg(self, self.__data, self.__test,
                                  '/home/tygrys')
            dlg.ShowModal()
            dlg.make_free_desktop()
            dlg.make_symlink()
            dlg.make_shortcut()
            log = dlg.get_log()
            dlg.Destroy()
            text = u'DELETE THE CREATET FILES IN THE HOME ' + \
                  'DIRECTORY AND ON THE DESKTOP.\n'
            text = text + u'get_def_dir.. ' + dlg.get_def_dir() + \
                   '\n'
            text = text + u'get_log..\n' + log
            dlg = PontonTextDlg(self, self.__data, cmd, text)
            dlg.ShowModal()
            dlg.Destroy()
        elif cmd == self.__ldic['instproc']:
            dlg = PontonInstProcDlg(self, self.__data, self.__test,
                                    self.__tool,
                                    '/home/tygrys/LORZEtesting')
            dlg.ShowModal()
            dlg.Destroy()
        elif cmd == self.__ldic['srcdir']:
            srcdir = self.__tool.read_src_dir()
            dlg = wx.MessageDialog(self, 'srcdir:\n' + srcdir, cmd,
                                   style=wx.OK)
            dlg.ShowModal()
            dlg.Destroy()
        elif cmd == self.__ldic['srclist']:
            srcdir = self.__tool.read_src_dir()
            srcdirlist, srcfilelist, repobool = self.__tool.\
                                                get_src_list(srcdir)
            text = 'REPOBOOL\n' + str(repobool) + '\n'
            text = text + '\nSRCDIRLIST\n'
            for i in srcdirlist:
                text = text + i + '\n'
            text = text + '\nSRCFILELIST\n'
            for i in srcfilelist:
                text = text + i + '\n'
            dlg = PontonTextDlg(self, self.__data, cmd, text)
            dlg.ShowModal()
            dlg.Destroy()
        elif cmd == self.__ldic['srcinst']:
            log = self.__tool.install_src('/home/tygrys/LORZEtesting')
            dlg = PontonTextDlg(self, self.__data, cmd, log)
            dlg.ShowModal()
            dlg.Destroy()
        elif cmd == self.__ldic['makestartscript']:
            log = self.__tool.make_start_bash('/home/tygrys')
            dlg = PontonTextDlg(self, self.__data, cmd, log)
            dlg.ShowModal()
            dlg.Destroy()

    def set_write_srcdir(self):
        '''Set and write 'srcdir.txt' for testing.'''
        srcdir = os.getcwd()
        try:
            txtfile = open('srcdir.txt', 'w')
            txtfile.write(srcdir)
            txtfile.close()
        except IOError:
            print(u'FAIL|write srcdir.txt')