def on_set_repo(self, evt):
     """set download directory according to value"""
     path = self.repo_value.GetValue()
     while path and not os.path.isdir(path):
         path = os.path.dirname(path)
     set_prefs("download_repo", path.encode(ENCODING))
     self.repo_value.SetValue(path)
     self.repo_button.SetToolTipString(path)
     self.SetTitle()
 def on_browse_repo(self, evt):
     """select download directory in DirDialog"""
     # pop up to choose repository
     dlg = wx.DirDialog(self, message=_("Choose location to download files into"),
                        defaultPath = force_unicode(get_prefs("download_repo")),
                        style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
     if dlg.ShowModal() == wx.ID_OK:
         # path chosen
         path = dlg.GetPath()
         set_prefs("download_repo", path.encode(ENCODING))
         self.repo_value.SetValue(path)
         self.repo_button.SetToolTipString(path)
         self.SetTitle()
     dlg.Destroy()
 def on_switch_mode(self, event): # wxGlade: EditProfilePanel.<event_handler>
     if self.all_label.IsShown():
         # switching to advanced
         self.mode_button.SetLabel(_("Simple Mode"))
         self.all_label.Hide()
         self.all_value.Hide()
         self.spacer_label.Hide()
         self.title_label.Show()
         self.title_value.Show()
         self.firstname_label.Show()
         self.firstname_value.Show()
         self.lastname_label.Show()
         self.lastname_value.Show()
         self.pseudo_label.Show()
         self.pseudo_value.Show()
         self.email_label.Show()
         self.email_value.Show()
         self.customs_label.Show()
         self.customs_list.Show()
         self.logic_checkbox.Show()
         set_prefs("simple_mode", False)
     else:
         # switching to simple
         self.mode_button.SetLabel(_("Advanced Mode"))
         self.all_label.Show()
         self.all_value.Show()
         self.spacer_label.Show()
         self.title_label.Hide()
         self.title_value.Hide()
         self.firstname_label.Hide()
         self.firstname_value.Hide()
         self.lastname_label.Hide()
         self.lastname_value.Hide()
         self.pseudo_label.Hide()
         self.pseudo_value.Hide()
         self.email_label.Hide()
         self.email_value.Hide()
         self.customs_label.Hide()
         self.customs_list.Hide()
         self.logic_checkbox.Hide()
         set_prefs("simple_mode", True)
     self.GetSizer().Layout()
     if not event is None:
         event.Skip()
 def test_downloads(self):
     def _on_test_profile(result):
         self.assert_(result)
         self.assert_profile(result)
     deferred = self.network.get_profile("boby")
     util.wait(deferred.addCallbacks(_on_test_profile, on_error))
     def _on_test_blog(result):
         self.assert_(result)
         self.assert_blog(result)
     deferred = self.network.get_blog_file("boby")
     util.wait(deferred.addCallbacks(_on_test_blog, on_error))
     def _on_test_shared_files(result):
         self.assert_(result)
         self.assert_files(result)
     deferred = self.network.get_shared_files("boby")
     util.wait(deferred.addCallbacks(_on_test_shared_files, on_error))
     def _on_test_files(result):
         file_name = os.path.join(GENERATED_DIR, "arc en ciel 6.gif")
         self.assert_(os.path.exists(file_name))
         self.assertEquals(163564, os.stat(file_name)[6])
         file_name = os.path.join(GENERATED_DIR, "02_b_1280x1024.jpg")
         self.assert_(os.path.exists(file_name))
         self.assertEquals(629622, os.stat(file_name)[6])
         file_name = os.path.join(GENERATED_DIR, "pywin32-203.win32-py2.3.exe")
         self.assert_(os.path.exists(file_name))
         self.assertEquals(3718120, os.stat(file_name)[6])
         file_name = os.path.join(GENERATED_DIR, "Python-2.3.5.zip")
         self.assert_(os.path.exists(file_name))
         self.assertEquals(9769010, os.stat(file_name)[6])
     get_facade().share_files(DATA_DIR,
                              ["arc en ciel 6.gif",
                               "02_b_1280x1024.jpg",
                               "pywin32-203.win32-py2.3.exe",
                               "Python-2.3.5.zip"],
                              share=True)
     set_prefs("download_repo", GENERATED_DIR)
     deferred = self.network.get_files("boby", [
         (DATA_DIR.split(os.sep) + ["arc en ciel 6.gif"], 163564),
         (DATA_DIR.split(os.sep) + ["02_b_1280x1024.jpg"], 629622),
         (DATA_DIR.split(os.sep) + ["pywin32-203.win32-py2.3.exe"], 3718120),
         (DATA_DIR.split(os.sep) + ["Python-2.3.5.zip"], 9769010)])
     return deferred.addCallbacks(_on_test_files, on_error)
 def on_close(self, evt=None):
     """hide  application"""
     # ask for saving
     if self.modified:
         self.do_modified(False)
         dlg = wx.MessageDialog(
             self,
             _('Your profile has been modified. Do you want to change it?'),
             _('Saving Dialog'),
             wx.YES_NO | wx.ICON_INFORMATION)
         if dlg.ShowModal() == wx.ID_YES:
             self.on_save(evt)
     # save size
     new_size = self.GetSize()
     set_prefs("profile_width", new_size.GetWidth())
     set_prefs("profile_height", new_size.GetHeight())
     # close dialog
     if self.options["standalone"]:
         self.profile_dlg.Destroy()
         self.Destroy()
         self.options['App'].ExitMainLoop()
     else:
         self.Hide()
 def on_check_display(self, evt):
     """set whether disclaimer will be displayed at startup or not"""
     set_prefs("display_dl", self.always_display_check.IsChecked())
Esempio n. 7
0
from logilab.common.testlib import main
from solipsis.services.profile.tools.prefs import get_prefs, set_prefs

if __name__ == '__main__':
    import sys, os
    logging = get_prefs("log")
    if not logging:
        print "desactivating log"
    set_prefs("log", False)
    main(os.path.dirname(sys.argv[0]) or '.')
    set_prefs("log", logging)