Beispiel #1
0
    def __init__(self, filename=None):
        """Create a new MainTable."""

        # self._projects: an array of Projects in this table
        self._projects = []
        self._platform = launcher.Platform()
        self._filename = filename or self._platform.ProjectsFile()
        self._LoadProjects(self._filename)
Beispiel #2
0
    def _TaskDidStop(self, returncode):
        """Update the UI to reflect that our project has stopped.

    Update the UI to reflect that the project has stopped, determining
    how it exited (failure / success) by looking at the return code.

    Args:
      returncode: The proces return (exit) code of the process this thread
                  is monitoring.
    """
        if launcher.Platform().IsSuccessfulCommandResultCode(returncode):
            self._ChangeProcessRunState(launcher.Project.STATE_STOP)
        else:
            self._ChangeProcessRunState(launcher.Project.STATE_DIED)
Beispiel #3
0
 def testPaste(self):
     ac = self.FakeAppController()
     self.frame = self.ClipboardMainFrame(None, -1, launcher.MainTable(),
                                          None, ac, None)
     # Pretend to paste a valid path.  This path should get to the fake
     # app controller.
     platform = launcher.Platform()
     self.frame.SetClipboardText(platform.AppEngineBaseDirectory())
     self.frame.OnPaste(None)
     self.assertEqual(platform.AppEngineBaseDirectory(), ac.GetPath())
     # Pretend to paste an invalid path.  The path should not find its way
     # to the fake app controller.
     self.frame.SetClipboardText('unga wunga bunga')
     ac.SetPath(None)
     self.frame.OnPaste(None)
     self.assertFalse(ac.GetPath())
Beispiel #4
0
  def __init__(self, app_controller):
    """Create a new TaskController.

    Args:
      app_controller: the main application controller.
     """
    self._app_controller = app_controller
    # self._frame: the main frame for project display
    # self._threads: an array of threads for running App Engine applicatons
    # self._consoles: an array of LogConsoles for App Engine applications
    self._frame = None
    self._threads = []
    self._consoles = []
    self._runtime = None
    self._platform = launcher.Platform()
    self._preferences = None
Beispiel #5
0
    def __init__(self, filename=None, platform=None):
        """Initialize our Preferences object.

    Args:
      filename: the preference filename.
        If None, use a platform-specific default.
      platform: a platform object.  Default is None.
    """
        self._platform = platform or launcher.Platform()
        self._filename = filename or self._platform.PreferencesFile()
        self._parser = ConfigParser.ConfigParser()
        self._pref_defaults = {
            self.PREF_PYTHON: self._platform.PythonCommand(),
            self.PREF_APPENGINE: self._platform.AppEngineBaseDirectory(),
            self.PREF_DEPLOY_SERVER: None,
            self.PREF_EDITOR: self._platform.DefaultEditor(),
            self.PREF_NOVERSIONCHECK: None,
        }
        self.Load()
    def _GetSDKEnvironmentSetting(self):
        """Return a brief string describing our SDK environment.

    Returns:
      a string suitable for setting in an environment variable, or '???'.
    """
        sdk_version = '???'
        sdk_dir = self._preferences[launcher.Preferences.PREF_APPENGINE]
        if sdk_dir:
            sdk_version_file = os.path.join(sdk_dir, 'VERSION')
            try:
                words = open(
                    sdk_version_file).readline().split()  # version: "1.1.9"
                if len(words) == 2:
                    sdk_version = words[1].replace('"', '')  # 1.1.9
            except IOError:
                pass
        sdk_env_setting = (
            '%s-launcher-%s' %
            (launcher.Platform().BriefPlatformName(), sdk_version))
        return sdk_env_setting
Beispiel #7
0
  def _BuildDemoMenu(self, demo_dir=None):
    """Build the demos menu, using projects in the given demo directory.

    Args:
      demo_dir: the directory that contains demos.  If None (e.g. if
        not unit testing), use a default.
    """
    # Build the demos menu.  Create an item for each demo.
    demo_menu = wx.Menu()
    sdk_directory = launcher.Platform().AppEngineBaseDirectory()
    if not demo_dir and not sdk_directory:
      return
    demo_directory = demo_dir or os.path.join(sdk_directory, 'demos')

    for demo in os.listdir(demo_directory):
      full_demo_path = os.path.join(demo_directory, demo)
      if os.path.isdir(full_demo_path):
        item = wx.MenuItem(demo_menu, -1, demo)
        demo_menu.AppendItem(item)
        self.Bind(wx.EVT_MENU, self._CreateDemoByNameFunction(full_demo_path),
                  item)

    # Find the old demo item and replace it.  This is a little
    # awkward, but it appears to be the consequence of mixing
    # wxGlade generated menus with manually created ones.
    if not demo_menu.GetMenuItemCount():
      return
    old_demo_item = self.GetMenuBar().FindItemById(self.ID_DEMOS_MENU)
    if not old_demo_item:
      # We get here in a unit test -- menubar not realized
      return
    menu = old_demo_item.GetMenu()
    for pos in range(menu.GetMenuItemCount()):
      if old_demo_item.Id == menu.FindItemByPosition(pos).Id:
        break
    menu.InsertMenu(pos, -1, 'Demos', demo_menu)
    menu.DeleteItem(old_demo_item)
 def testSingleton(self):
     p1 = launcher.Platform()
     p2 = launcher.Platform()
     self.assertEqual(id(self.platform), id(p1))
     self.assertEqual(id(p1), id(p2))
 def setUp(self):
     self.platform = launcher.Platform()
    def _PlatformObject(self):
        """Return a platform object.

    Split out for easier unit testing
    """
        return launcher.Platform()
Beispiel #11
0
 def testDefaultEditor(self):
     p = launcher.Preferences('/foo', launcher.Platform())
     editor = p.GetDefault(launcher.Preferences.PREF_EDITOR)
     self.assertTrue(os.path.exists(editor))
Beispiel #12
0
 def testGetSDKEnvironmentSetting(self):
   pref = launcher.Preferences(self.filename, platform=launcher.Platform())
   runtime = RuntimeNoDialog(preferences=pref)
   sdk_env = runtime._GetSDKEnvironmentSetting()
   self.assertTrue('-launcher-' in sdk_env)
   self.assertTrue('\n' not in sdk_env)