예제 #1
0
    def managedByAutostart(self, on):
        if on:
            tryMkdir(os.path.dirname(constants.AUTOSTART_DESKTOP_USERFILE))

            trySymlink(constants.AUTOSTART_DESKTOP_FILE,
                       constants.AUTOSTART_DESKTOP_USERFILE)
        else:
            tryRemove(constants.AUTOSTART_DESKTOP_USERFILE)
예제 #2
0
    def daemonManagedByAutostart(self, on):
        if on:
            tryMkdir(os.path.dirname(constants.AUTOSTART_DESKTOP_USERFILE))

            trySymlink(constants.AUTOSTART_DESKTOP_FILE,
                       constants.AUTOSTART_DESKTOP_USERFILE)
        else:
            tryRemove(constants.AUTOSTART_DESKTOP_USERFILE)
예제 #3
0
    def autoStart(self, on):
        if on:
            # mkdir if autostart dir doesn't exist
            misc.tryMkdir(os.path.dirname(constants.DESKTOP_AUTOSTART_FILE))

            misc.trySymlink(constants.DESKTOP_FILE,
                            constants.DESKTOP_AUTOSTART_FILE)
        else:
            misc.tryRemove(constants.DESKTOP_AUTOSTART_FILE)
예제 #4
0
    def autoStart(self, on):
        if on:
            # mkdir if autostart dir doesn't exist
            misc.tryMkdir(os.path.dirname(constants.DESKTOP_AUTOSTART_FILE))

            misc.trySymlink(constants.DESKTOP_FILE,
                            constants.DESKTOP_AUTOSTART_FILE)
        else:
            misc.tryRemove(constants.DESKTOP_AUTOSTART_FILE)
예제 #5
0
    def daemonManagedByUpstart(self, on):
        if on:
            tryMkdir(os.path.dirname(constants.UPSTART_SERVICE_USERFILE))

            trySymlink(constants.UPSTART_SERVICE_FILE,
                       constants.UPSTART_SERVICE_USERFILE)
        else:
            tryRemove(constants.UPSTART_SERVICE_USERFILE)
        if getInitType() == InitType.UPSTART:
            os.system("initctl --user reload-configuration")
예제 #6
0
    def managedByUpstart(self, on):
        if on:
            tryMkdir(os.path.dirname(constants.UPSTART_SERVICE_USERFILE))

            trySymlink(constants.UPSTART_SERVICE_FILE,
                       constants.UPSTART_SERVICE_USERFILE)
        else:
            tryRemove(constants.UPSTART_SERVICE_USERFILE)
        if getInitType() == InitType.UPSTART:
            os.system("initctl --user reload-configuration")
예제 #7
0
    def daemonManagedBySystemd(self, on):
        if on:
            tryMkdir(os.path.dirname(constants.SYSTEMD_SERVICE_ENABLED_USERFILE))

            trySymlink(constants.SYSTEMD_SERVICE_FILE,
                       constants.SYSTEMD_SERVICE_USERFILE)

            trySymlink(constants.SYSTEMD_SERVICE_USERFILE,
                       constants.SYSTEMD_SERVICE_ENABLED_USERFILE)
        else:
            tryRemove(constants.SYSTEMD_SERVICE_ENABLED_USERFILE)
            tryRemove(constants.SYSTEMD_SERVICE_USERFILE)
        if getInitType() == InitType.SYSTEMD:
            os.system("systemctl --user daemon-reload")
예제 #8
0
    def managedBySystemd(self, on):
        if on:
            tryMkdir(os.path.dirname(constants.SYSTEMD_SERVICE_ENABLED_USERFILE))

            trySymlink(constants.SYSTEMD_SERVICE_FILE,
                       constants.SYSTEMD_SERVICE_USERFILE)

            trySymlink(constants.SYSTEMD_SERVICE_USERFILE,
                       constants.SYSTEMD_SERVICE_ENABLED_USERFILE)
        else:
            tryRemove(constants.SYSTEMD_SERVICE_ENABLED_USERFILE)
            tryRemove(constants.SYSTEMD_SERVICE_USERFILE)
        if getInitType() == InitType.SYSTEMD:
            os.system("systemctl --user daemon-reload")
예제 #9
0
    def _mountBootstrap(localPath):
        # local/path is the path that user sets
        # after bootstraping, return the path to PROFILE/mnt/local\path

        # the filter(bool) part is to remove the "/" at the beginning
        backslashed = "\\".join(filter(bool, localPath.split("/")))

        mntDir = os.path.join(constants.PROFILE_DIR, "mnt", backslashed)

        tddownloadDir = os.path.join(mntDir, "TDDOWNLOAD")
        thunderdbDir = os.path.join(mntDir, "ThunderDB")

        tryMkdir(thunderdbDir)
        trySymlink(localPath, tddownloadDir)

        return mntDir
예제 #10
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import os, sys

sys.path.append(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))

if __name__ == "__main__":
    import faulthandler, logging
    from logging import handlers
    from utils import misc
    misc.tryMkdir(os.path.expanduser("~/.xware-desktop"))

    loggingHandler = logging.handlers.RotatingFileHandler(
        os.path.expanduser("~/.xware-desktop/log.txt"),
        maxBytes=1024 * 1024 * 5,
        backupCount=5)
    logging.basicConfig(
        handlers=(loggingHandler, ),
        format="%(asctime)s %(levelname)s:%(name)s:%(message)s")

    faultLogFd = open(
        os.path.expanduser('~/.xware-desktop/frontend.fault.log'), 'a')
    faulthandler.enable(faultLogFd)

    from CrashReport import CrashAwareThreading
    CrashAwareThreading.installCrashReport()
    CrashAwareThreading.installThreadExceptionHandler()

from PyQt5.QtCore import pyqtSlot, pyqtSignal
예제 #11
0
# -*- coding: utf-8 -*-

import os, sys
if sys.platform == "linux":
    if os.getuid() == 0:
        print("拒绝以root执行。", file = sys.stderr)
        sys.exit(1)

sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../shared/thirdparty"))

if __name__ == "__main__":
    import faulthandler, logging
    from logging import handlers
    from utils import misc
    misc.tryMkdir(os.path.expanduser("~/.xware-desktop"))

    loggingHandler = logging.handlers.RotatingFileHandler(
        os.path.expanduser("~/.xware-desktop/log.txt"),
        maxBytes = 1024 * 1024 * 5,
        backupCount = 5)
    logging.basicConfig(handlers = (loggingHandler,),
                        format = "%(asctime)s %(levelname)s:%(name)s:%(message)s")

    faultLogFd = open(os.path.expanduser('~/.xware-desktop/frontend.fault.log'), 'a')
    faulthandler.enable(faultLogFd)

    from CrashReport import CrashAwareThreading
    CrashAwareThreading.installCrashReport()
    CrashAwareThreading.installThreadExceptionHandler()
    CrashAwareThreading.installEventLoopExceptionHandler()