Exemplo n.º 1
0
    def _execute(self):
        foreground = self._pending == SYNC_NOW_FG
        self._pending = NO_SYNC

        if app.get().status is interfaces.STATUS_SYNCING:
            print 'Syncer quit: already syncing'
            return

        elif app.get().status is interfaces.STATUS_DISABLED:
            print 'Syncer quit: app is disabled'
            return

        else:
            app.get().set_status(interfaces.STATUS_SYNCING)

        if foreground:
            cmd = terminal_cmd_template % '%s -auto' % (
                CONFIG.unison_executable)
        else:
            cmd = '%s -batch' % CONFIG.unison_executable

        try:
            self._finished(self._runcmd(cmd))
        except Exception, exc:
            # XXX improve error handling
            print str(exc)
            self._finished(False)
            raise exc
Exemplo n.º 2
0
    def _execute(self):
        foreground = self._pending == SYNC_NOW_FG
        self._pending = NO_SYNC

        if app.get().status is interfaces.STATUS_SYNCING:
            print 'Syncer quit: already syncing'
            return

        elif app.get().status is interfaces.STATUS_DISABLED:
            print 'Syncer quit: app is disabled'
            return

        else:
            app.get().set_status(interfaces.STATUS_SYNCING)

        if foreground:
            cmd = terminal_cmd_template % '%s -auto' % (
                CONFIG.unison_executable)
        else:
            cmd = '%s -batch' % CONFIG.unison_executable

        try:
            self._finished(self._runcmd(cmd))
        except Exception, exc:
            # XXX improve error handling
            print str(exc)
            self._finished(False)
            raise exc
Exemplo n.º 3
0
    def run(self):
        self.running = True
        now = datetime.now()
        next = self.iter.get_next()

        timeout = next - time.mktime(now.timetuple())
        for sec in range(int(timeout)):
            time.sleep(1)
            if self.running == False:
                return

        app.get().sync()
Exemplo n.º 4
0
    def run(self):
        self.running = True
        now = datetime.now()
        next = self.iter.get_next()

        timeout = next - time.mktime(now.timetuple())
        for sec in range(int(timeout)):
            time.sleep(1)
            if self.running == False:
                return

        app.get().sync()
Exemplo n.º 5
0
    def applicationDidFinishLaunching_(self, notification):
        self._menu_items = {}

        self.statusbar = NSStatusBar.systemStatusBar()
        self._create_statusitem()
        self._create_menu()
        self._create_timer()

        self._syncing_icon_timer = None
        self._last_icon = None

        # sync on boot
        self.change_icon('inactive')
        app.get().sync(now=True)
Exemplo n.º 6
0
    def applicationDidFinishLaunching_(self, notification):
        self._menu_items = {}

        self.statusbar = NSStatusBar.systemStatusBar()
        self._create_statusitem()
        self._create_menu()
        self._create_timer()

        self._syncing_icon_timer = None
        self._last_icon = None

        # sync on boot
        self.change_icon('inactive')
        app.get().sync(now=True)
Exemplo n.º 7
0
    def _create_menu(self):
        self.menu = NSMenu.alloc().init()
        self.menu.setAutoenablesItems_(False)
        self.trayicon.setMenu_(self.menu)

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            'Status: loading', '', '')
        menuitem.setEnabled_(False)
        self._menu_items['status'] = menuitem
        self.menu.addItem_(menuitem)

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            'Sync now', 'sync:', '')
        menuitem.setEnabled_(False)
        self._menu_items['sync'] = menuitem
        self.menu.addItem_(menuitem)

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            'Resolve conflicts', 'resolve:', '')
        menuitem.setEnabled_(False)
        self._menu_items['resolve'] = menuitem
        self.menu.addItem_(menuitem)

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            app.get().status == interfaces.STATUS_DISABLED \
                and 'Enable' or 'Disable',
            'enabledisable:', '')
        self._menu_items['enable_disable'] = menuitem
        self.menu.addItem_(menuitem)

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            'Quit', 'terminate:', '')
        self._menu_items['quit'] = menuitem
        self.menu.addItem_(menuitem)
Exemplo n.º 8
0
    def _create_menu(self):
        self.menu = NSMenu.alloc().init()
        self.menu.setAutoenablesItems_(False)
        self.trayicon.setMenu_(self.menu)

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            'Status: loading', '', '')
        menuitem.setEnabled_(False)
        self._menu_items['status'] = menuitem
        self.menu.addItem_(menuitem)

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            'Sync now', 'sync:', '')
        menuitem.setEnabled_(False)
        self._menu_items['sync'] = menuitem
        self.menu.addItem_(menuitem)

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            'Resolve conflicts', 'resolve:', '')
        menuitem.setEnabled_(False)
        self._menu_items['resolve'] = menuitem
        self.menu.addItem_(menuitem)

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            app.get().status == interfaces.STATUS_DISABLED \
                and 'Enable' or 'Disable',
            'enabledisable:', '')
        self._menu_items['enable_disable'] = menuitem
        self.menu.addItem_(menuitem)

        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            'Quit', 'terminate:', '')
        self._menu_items['quit'] = menuitem
        self.menu.addItem_(menuitem)
Exemplo n.º 9
0
def sigint_handler(signum, frame):
    app.get().quit()
    signal.signal(signal.SIGINT, signal.default_int_handler)
Exemplo n.º 10
0
 def tick_(self, notification):
     last_status = getattr(self, '_last_status', None)
     current_status = app.get().status
     if last_status != current_status:
         self.status_changed(current_status)
         self._last_status = current_status
Exemplo n.º 11
0
 def terminate_(self, notification):
     app.get().quit()
     super(TrayMenu, self).terminate_()
Exemplo n.º 12
0
 def enabledisable_(self, notification):
     if app.get().status == interfaces.STATUS_DISABLED:
         app.get().set_status(interfaces.STATUS_INACTIVE)
         app.get().sync(now=True)
     else:
         app.get().set_status(interfaces.STATUS_DISABLED)
Exemplo n.º 13
0
 def resolve_(self, notification):
     app.get().sync(foreground=True)
Exemplo n.º 14
0
 def sync_(self, notification):
     app.get().sync(now=True)
Exemplo n.º 15
0
 def enabledisable_(self, notification):
     if app.get().status == interfaces.STATUS_DISABLED:
         app.get().set_status(interfaces.STATUS_INACTIVE)
         app.get().sync(now=True)
     else:
         app.get().set_status(interfaces.STATUS_DISABLED)
Exemplo n.º 16
0
 def resolve_(self, notification):
     app.get().sync(foreground=True)
Exemplo n.º 17
0
 def terminate_(self, notification):
     app.get().quit()
     super(TrayMenu, self).terminate_()
Exemplo n.º 18
0
 def _finished(self, exitcode):
     if exitcode == 0:
         app.get().set_status(interfaces.STATUS_OK)
     else:
         app.get().set_status(interfaces.STATUS_CONFLICT)
Exemplo n.º 19
0
 def tick_(self, notification):
     last_status = getattr(self, '_last_status', None)
     current_status = app.get().status
     if last_status != current_status:
         self.status_changed(current_status)
         self._last_status = current_status
Exemplo n.º 20
0
    def on_any_event(self, event):
        paths = [event.src_path]
        if getattr(event, 'dest_path', None):
            paths.append(event.dest_path)

        app.get().sync()
Exemplo n.º 21
0
    def on_any_event(self, event):
        paths = [event.src_path]
        if getattr(event, 'dest_path', None):
            paths.append(event.dest_path)

        app.get().sync()
Exemplo n.º 22
0
 def _finished(self, exitcode):
     if exitcode == 0:
         app.get().set_status(interfaces.STATUS_OK)
     else:
         app.get().set_status(interfaces.STATUS_CONFLICT)
Exemplo n.º 23
0
 def sync_(self, notification):
     app.get().sync(now=True)