Beispiel #1
0
 def apphost(project_name,
             user=None,
             host=None,
             station_class=None,
             match_station_class=True):
     '''
     If user or host are None, the current user and current host name 
     are used, leading to the url of a local apphost.
     
     If the station_class is None, the current station_class is used.
     
     If match_station_class is True, the station_class must match the current
     station class. Use this to ensure the client is compatible with the 
     apphost pointed by the returned url.
     '''
     user = user or get_user_name()
     host = host or socket.gethostname()
     if station_class is None:
         station_class = get_station_class()
     if match_station_class:
         if station_class != get_station_class():
             raise UrlError(
                 'Access to apphost with a station class %r is forbidden '
                 '(your class is %r)' %
                 (station_class, get_station_class()))
     return '%s/project/%s/apphost/%s/%s/%s' % (URL_ROOT, project_name,
                                                station_class, host, user)
Beispiel #2
0
    def set_connected(self):
        '''
        User must call this when the client gets connected to
        an AppHost.
        '''
        self.model.set_connected()

        self._root_names = {}

        # find root names
        root_id = self.model.root().node_id()
        for node_id in self.client.apps.FLOW.cmds.GetRootChildren():
            root_name = node_id[-1]
            self.add_root_name(root_name, node_id)

        for name, node_id in self._extra_root_names.items():
            full_id = root_id + node_id
            self.add_root_name(name, full_id)

        self.menu_bar.set_root_names(self, sorted(self._root_names.keys()))

        # find bookmarks
        self._bookmarks = self.client.apps.USERS.cmds.GetUserData(
            login=get_user_name(), data_id='flow_bookmarked_uid')
        self.menu_bar.set_bookmark_names(self,
                                         sorted(self._live_bookmarks.keys()),
                                         sorted(self._bookmarks.keys()))
Beispiel #3
0
    def __init__(self, parent, controller, options):
        QtGui.QWidget.__init__(self, parent)

        self.setLayout(QtGui.QHBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)

        self._label = QtGui.QLabel(self)
        self.layout().addWidget(self._label)

        self._original_tooltip = ''

        self._display_mode = options.get('display_mode', 'count')
        self._currency = options.get('currency', 'user(s)')
        self._add_text = options.get('add', 'Add Me')
        self._remove_text = options.get('remove', 'Remove Me')
        self._is_in = None
        self._current_login = get_user_name()
        self._edited = None

        self._toggle_button = QtGui.QPushButton('Toggle', self)
        self._toggle_button.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self._toggle_button.customContextMenuRequested.connect(
            self._on_button_menu)
        self.layout().addWidget(self._toggle_button)

        ValueEditorMixin.__init__(self, controller, options)
Beispiel #4
0
 def save_to_preset(self, preset_name):
     preset_data = self.qb.to_preset()
     with self.client.result_to(self._preset_saved):
         self.client.apps.USERS.cmds.SetUserData(login=get_user_name(),
                                                 data_id='search_presets',
                                                 key=preset_name,
                                                 value=preset_data)
Beispiel #5
0
    def get_workers_infos(self, this_user_only=False, this_host_only=False):
        user = this_user_only and get_user_name() or None
        host = this_host_only and this_host() or None

        if not self._current_future_target:
            return self.apphost.get_workers_infos(user, host)
        #else:
        future = self.async_apphost.get_workers_infos(user, host)
        future._on_result, future._on_err = self._current_future_target[-1]
        self._futures.add(future)
Beispiel #6
0
 def load_preset_menu(self):
     self.preset_menu.addAction('Save Preset...',
                                self._on_save_preset_dialog)
     self.preset_menu.addAction('Delete a Preset...',
                                self._on_delete_preset_dialog)
     self.preset_menu.addSeparator()
     self.preset_menu.addAction('Reset', lambda: self.qb.load_preset({}))
     self.preset_menu.addSeparator()
     with self.client.result_to(self._receive_presets):
         self.client.apps.USERS.cmds.GetUserData(login=get_user_name(),
                                                 data_id='search_presets')
Beispiel #7
0
    def delete_bookmark(self, bookmark_name):
        # store the new bookmark in user data
        with self.client.result_to(lambda ret: None):
            self.client.apps.USERS.cmds.SetUserData(
                login=get_user_name(),
                data_id='flow_bookmarked_uid',
                key=bookmark_name,
                value=None)

        # update this view's bookmarks
        # TODO: we should listen to an UPDATED event on the user data and update
        # so that all NodeTreePanel have sync'ed bookmarks.
        # This is not clean at all:
        del self._bookmarks[bookmark_name]
        self.menu_bar.set_bookmark_names(self,
                                         sorted(self._live_bookmarks.keys()),
                                         sorted(self._bookmarks.keys()))
Beispiel #8
0
 def __init__(self, data):
     super(VersionsModel.Entry, self).__init__()
     self.data = data
     
     self.is_mine = self.data.get('owner') == get_user_name()
     
     rev_time = self.data.get('time')
     self.date_label = rev_time.ctime()
     if rev_time.date() == datetime.date.today():
         self.date_label = rev_time.strftime('%H:%M')
         
     if self.data['rev_type'] == 'w' and 'WORK' in self.data.get('versions'):
         color_name = self.is_mine and 'my_pending' or 'pending'
     else:
         color_name = self.data['rev_type']
     self.bg_color = get_style_value(
         'revision_colors', color_name,
         '#FF0000'
     )
Beispiel #9
0
 def refresh(self):
     if not self.client.connected():
         self.set_status('Not Connected.')
         self.load_finished.emit()
         return
     
     if self.filename is None:
         self._model._clear()
         self.resizeColumnsToContents()
         self.set_status('No filename.')
         self.load_finished.emit()
         return
     
     with self.client.result_to(self._history_data_ready):
         self.set_status('Loading...')
         self.client.apps.VERSIONS.cmds.GetHistory(
             self.filename,
             get_user_name(),
             self._show_versions_only
         )
Beispiel #10
0
    def _host_init_done(self):
        print '#---   Initializing Flow'

        project_name = self.host.project_name
        
        #----- Configure the App
        self.batch_temp_path = os.path.join(
            self.host.get_project_dir('LOGS'),
            'FlowBatch',
            utils.get_user_name()
        )

        #----- Init and configure the flow instance
        self.flow = self.flow_class(project_name)
        
        # callbacks
        self.flow.set_on_param_touched_func(self._on_param_touched)
        
        # naming
        self.flow.set_named_store(self.NAMING.get_root('STORE'))
        self.flow.set_root_class(self.root_class)
        
        # system cmds
        self.flow.set_system_cmds_app(self.CMDS)
        
        # users
        self.flow.set_users_app(self.USERS)
        
        # root case, using db 
        project_case = self.case_class(('Project',), self.root_class.type_names())
        collection = self.DB.get_collection(
            'FLOW.'+self.root_class.__name__, ['type_names', '_id']
        )
        project_case.set_DB_collection(collection)
            
        project_case.load()
        
        #----- Init root node
        root = self.flow.init_root(project_case, 'Project')
        print '  Ok. (root: %r)'%(root,)
Beispiel #11
0
 def client(project_name, client_name, user=None, host=None):
     user = user or get_user_name()
     host = host or socket.gethostname()
     return '%s/project/%s/client/%s/%s/%s' % (URL_ROOT, project_name, host,
                                               user, client_name)
Beispiel #12
0
 def delete_preset(self, preset_name):
     with self.client.result_to(self._preset_deleted):
         self.client.apps.USERS.cmds.SetUserData(login=get_user_name(),
                                                 data_id='search_presets',
                                                 key=preset_name,
                                                 value=None)
Beispiel #13
0
 def get_user(self):
     return get_user_name()