Exemplo n.º 1
0
    def __init__(self):
        self.scanStack = []
        self.allvfs = {}
        self.inv_dirs = set()

        from tortoisehg.util import menuthg
        self.hgtk = paths.find_in_path(thg_main)
        self.menu = menuthg.menuThg()

        # Get the configuration directory path
        try:
            self.notify = os.environ['XDG_CONFIG_HOME']
        except KeyError:
            self.notify = os.path.join('$HOME', '.config')

        self.notify = os.path.expandvars(
            os.path.join(self.notify, 'TortoiseHg'))

        # Create folder if it does not exist
        if not os.path.isdir(self.notify):
            os.makedirs(self.notify)

        # Create the notify file
        self.notify = os.path.join(self.notify, 'notify')
        open(self.notify, 'w').close()

        self.gmon = Gio.file_new_for_path(self.notify).monitor(
            Gio.FileMonitorFlags.NONE, None)
        self.gmon.connect('changed', self.notified)
Exemplo n.º 2
0
    def runproc(self):
        'Run mercurial command in separate process'

        exepath = None
        if hasattr(sys, 'frozen'):
            progdir = paths.get_prog_root()
            exe = os.path.join(progdir, 'hg.exe')
            if os.path.exists(exe):
                exepath = exe
        if not exepath:
            exepath = paths.find_in_path('hg')

        def start(cmdline, display):
            self.rawoutlines = []
            if display:
                cmd = '%% hg %s\n' % display
            else:
                cmd = '%% hg %s\n' % ' '.join(cmdline)
            self.output.emit(cmd, 'control')
            proc.start(exepath, cmdline, QIODevice.ReadOnly)

        @pyqtSlot(int)
        def finished(ret):
            if ret:
                msg = _('[command returned code %d %%s]') % int(ret)
            else:
                msg = _('[command completed successfully %s]')
            msg = msg % time.asctime() + '\n'
            self.output.emit(msg, 'control')
            if ret == 0 and self.queue:
                start(self.queue.pop(0), '')
            else:
                self.queue = []
                self.extproc = None
                self.commandFinished.emit(ret)

        def handleerror(error):
            if error == QProcess.FailedToStart:
                self.output.emit(_('failed to start command\n'), 'ui.error')
                finished(-1)
            elif error != QProcess.Crashed:
                self.output.emit(_('error while running command\n'),
                                 'ui.error')

        def stdout():
            data = proc.readAllStandardOutput().data()
            self.rawoutlines.append(data)
            self.output.emit(hglib.tounicode(data), '')

        def stderr():
            data = proc.readAllStandardError().data()
            self.output.emit(hglib.tounicode(data), 'ui.error')

        self.extproc = proc = QProcess(self)
        proc.started.connect(self.onCommandStarted)
        proc.finished.connect(finished)
        proc.readyReadStandardOutput.connect(stdout)
        proc.readyReadStandardError.connect(stderr)
        proc.error.connect(handleerror)
        start(self.queue.pop(0), self.display)
Exemplo n.º 3
0
    def __init__(self):
        self.scanStack = []
        self.allvfs = {}
        self.inv_dirs = set()

        from tortoisehg.util import menuthg
        self.hgtk = paths.find_in_path(thg_main)
        self.menu = menuthg.menuThg()

        # Get the configuration directory path
        try:
            self.notify = os.environ['XDG_CONFIG_HOME']
        except KeyError:
            self.notify = os.path.join('$HOME', '.config')

        self.notify = os.path.expandvars(os.path.join(
            self.notify,
            'TortoiseHg'))

        # Create folder if it does not exist
        if not os.path.isdir(self.notify):
            os.makedirs(self.notify)

        # Create the notify file
        self.notify = os.path.join(self.notify, 'notify')
        open(self.notify, 'w').close()

        self.gmon = Gio.file_new_for_path(self.notify).monitor(Gio.FileMonitorFlags.NONE, None)
        self.gmon.connect('changed', self.notified)
Exemplo n.º 4
0
    def runproc(self):
        "Run mercurial command in separate process"

        exepath = None
        if hasattr(sys, "frozen"):
            progdir = paths.get_prog_root()
            exe = os.path.join(progdir, "hg.exe")
            if os.path.exists(exe):
                exepath = exe
        if not exepath:
            exepath = paths.find_in_path("hg")

        def start(cmdline, display):
            self.rawoutlines = []
            if display:
                cmd = "%% hg %s\n" % display
            else:
                cmd = "%% hg %s\n" % " ".join(cmdline)
            self.output.emit(cmd, "control")
            proc.start(exepath, cmdline, QIODevice.ReadOnly)

        @pyqtSlot(int)
        def finished(ret):
            if ret:
                msg = _("[command returned code %d %%s]") % int(ret)
            else:
                msg = _("[command completed successfully %s]")
            msg = msg % time.asctime() + "\n"
            self.output.emit(msg, "control")
            if ret == 0 and self.queue:
                start(self.queue.pop(0), "")
            else:
                self.queue = []
                self.extproc = None
                self.commandFinished.emit(ret)

        def handleerror(error):
            if error == QProcess.FailedToStart:
                self.output.emit(_("failed to start command\n"), "ui.error")
                finished(-1)
            elif error != QProcess.Crashed:
                self.output.emit(_("error while running command\n"), "ui.error")

        def stdout():
            data = proc.readAllStandardOutput().data()
            self.rawoutlines.append(data)
            self.output.emit(hglib.tounicode(data), "")

        def stderr():
            data = proc.readAllStandardError().data()
            self.output.emit(hglib.tounicode(data), "ui.error")

        self.extproc = proc = QProcess(self)
        proc.started.connect(self.onCommandStarted)
        proc.finished.connect(finished)
        proc.readyReadStandardOutput.connect(stdout)
        proc.readyReadStandardError.connect(stderr)
        proc.error.connect(handleerror)
        start(self.queue.pop(0), self.display)
Exemplo n.º 5
0
def _findhgexe():
    exepath = None
    if hasattr(sys, 'frozen'):
        progdir = paths.get_prog_root()
        exe = os.path.join(progdir, 'hg.exe')
        if os.path.exists(exe):
            exepath = exe
    if not exepath:
        exepath = paths.find_in_path('hg')
    return exepath
Exemplo n.º 6
0
def _findhgexe():
    exepath = None
    if hasattr(sys, 'frozen'):
        progdir = paths.get_prog_root()
        exe = os.path.join(progdir, 'hg.exe')
        if os.path.exists(exe):
            exepath = exe
    if not exepath:
        exepath = paths.find_in_path('hg')
    return exepath
Exemplo n.º 7
0
    def __init__(self):
        self.scanStack = []
        self.allvfs = {}
        self.inv_dirs = set()

        from tortoisehg.util import menuthg
        self.hgtk = paths.find_in_path(thg_main)
        self.menu = menuthg.menuThg()
        self.notify = os.path.expanduser('~/.tortoisehg/notify')
        try:
            f = open(self.notify, 'w')
            f.close()
            ds_uri = gnomevfs.get_uri_from_local_path(self.notify)
            self.gmon = gnomevfs.monitor_add(ds_uri,
                      gnomevfs.MONITOR_FILE, self.notified)
        except (gnomevfs.NotSupportedError, IOError), e:
            debugf('no notification because of %s', e)
            self.notify = ''
Exemplo n.º 8
0
    def __init__(self):
        self.scanStack = []
        self.allvfs = {}
        self.inv_dirs = set()

        from tortoisehg.util import menuthg
        self.hgtk = paths.find_in_path(thg_main)
        self.menu = menuthg.menuThg()
        self.notify = os.path.expanduser('~/.tortoisehg/notify')

        try:
            f = open(self.notify, 'w')
            f.close()
            ds_uri = matevfs.get_uri_from_local_path(self.notify)
            self.gmon = matevfs.monitor_add(ds_uri, matevfs.MONITOR_FILE,
                                            self.notified)
        except (matevfs.NotSupportedError, IOError), e:
            debugf('no notification because of %s', e)
            self.notify = ''