Beispiel #1
0
def main():
    global win
    signal.signal(signal.SIGINT, exit)
    args = parse_arguments()
    appKey = "scudcloud.pid"
    socket = QLocalSocket()
    socket.connectToServer(appKey)
    if socket.isOpen():
        socket.close()
        socket.deleteLater()
        return 0
    socket.deleteLater()
    app = QtGui.QApplication(sys.argv)
    app.setApplicationName(Resources.APP_NAME)
    app.setWindowIcon(QtGui.QIcon(Resources.get_path('scudcloud.png')))

    try:
        settings_path = load_settings(args.confdir)
    except:
        print("Configuration directory " + args.confdir +\
              " could not be created! Exiting...")
        raise SystemExit()
    minimized = True if args.minimized is True else None

    win = sca.ScudCloud(debug=args.debug, minimized=minimized, settings_path=settings_path)
    app.commitDataRequest.connect(win.setForceClose, type=QtCore.Qt.DirectConnection)

    server = QLocalServer()
    server.newConnection.connect(restore)
    server.listen(appKey)
    win.restore()
    if win.minimized is None:
        win.show()
    sys.exit(app.exec_())
Beispiel #2
0
def main():
    global win
    signal.signal(signal.SIGINT, exit)
    args = parse_arguments()
    appKey = "scudcloud.pid"
    socket = QLocalSocket()
    socket.connectToServer(appKey)
    if socket.isOpen():
        socket.close()
        socket.deleteLater()
        return 0
    socket.deleteLater()
    app = QtGui.QApplication(sys.argv)
    app.setApplicationName(Resources.APP_NAME+' Slack_SSB')
    app.setWindowIcon(QtGui.QIcon(Resources.get_path('scudcloud.png')))

    try:
        settings_path = load_settings(args.confdir)
    except:
        print("Configuration directory " + args.confdir +\
              " could not be created! Exiting...")
        raise SystemExit()
    minimized = True if args.minimized is True else None
    urgent_hint = True if args.urgent_hint is True else None

    win = sca.ScudCloud(debug=args.debug, minimized=minimized, urgent_hint=urgent_hint, settings_path=settings_path)
    app.commitDataRequest.connect(win.setForceClose, type=QtCore.Qt.DirectConnection)

    server = QLocalServer()
    server.newConnection.connect(restore)
    server.listen(appKey)
    win.restore()
    if win.minimized is None:
        win.show()
    sys.exit(app.exec_())
class AcrobatProxyListener(QLocalServer):
    # Signals
    new_path = pyqtSignal(str)

    def __init__(self, parent=None):
        super(AcrobatProxyListener, self).__init__(parent)
        self.newConnection.connect(self.on_new_connection)
        self.local_socket = QLocalSocket()

    def start(self):
        success = self.listen('Acrobat-Proxy-Listener')
        print 'Listening for Acrobat paths...'
        return success

    def stop(self):
        success = self.close()
        print 'Stopped listening for Acrobat paths'
        return success

    def on_new_connection(self):
        print 'NEW CONNECTION'
        self.local_socket = self.nextPendingConnection()
        self.local_socket.readyRead.connect(self.on_ready_read)

    def on_ready_read(self):
        print 'READING...'
        data = str(self.local_socket.readAll())
        self.local_socket.close()
        self.local_socket.deleteLater()
        print 'New path:', data
        self.new_path.emit(data)
    def __isServerRun(self, servername):  # 判断是否有一个同名的服务器在运行
        #  用一个localsocket去连一下,
        #  如果能连上就说明 有一个在运行了
        ls = QLocalSocket()

        ls.connectToServer(servername)
        if (ls.waitForConnected(1000)):
            ls.disconnectFromServer()  # // 说明已经在运行了
            ls.close()
            return  True
        return False
Beispiel #5
0
    def __isServerRun(self, servername):  # 判断是否有一个同名的服务器在运行
        #  用一个localsocket去连一下,
        #  如果能连上就说明 有一个在运行了
        ls = QLocalSocket()

        ls.connectToServer(servername)
        if (ls.waitForConnected(1000)):
            ls.disconnectFromServer()  # // 说明已经在运行了
            ls.close()
            return True
        return False
Beispiel #6
0
def main():
    global win
    signal.signal(signal.SIGINT, exit)
    args = parse_arguments()
    appKey = "scudcloud.pid"
    socket = QLocalSocket()
    socket.connectToServer(appKey)
    if socket.isOpen():
        socket.close()
        socket.deleteLater()
        return 0
    socket.deleteLater()
    app = QtGui.QApplication(sys.argv)
    app.setApplicationName(Resources.APP_NAME + ' Slack_SSB')
    app.setWindowIcon(QtGui.QIcon(Resources.get_path('scudcloud.png')))

    try:
        settings_path, cache_path = load_settings(args.confdir, args.cachedir)
    except:
        print("Data directories " + args.confdir + " and " + args.cachedir +
              " could not be created! Exiting...")
        raise SystemExit()
    minimized = True if args.minimized is True else None
    urgent_hint = True if args.urgent_hint is True else None

    # Let's move the CSS to cachedir to enable additional actions
    copyfile(Resources.get_path('resources.css'),
             os.path.join(cache_path, 'resources.css'))

    win = sca.ScudCloud(debug=args.debug,
                        minimized=minimized,
                        urgent_hint=urgent_hint,
                        settings_path=settings_path,
                        cache_path=cache_path)
    app.commitDataRequest.connect(win.setForceClose,
                                  type=QtCore.Qt.DirectConnection)

    server = QLocalServer()
    server.newConnection.connect(restore)
    server.listen(appKey)
    win.restore()
    if win.minimized is None:
        win.show()
    sys.exit(app.exec_())
Beispiel #7
0
def main():
    app = QtGui.QApplication(sys.argv)
    androidToolsMainWin = AndroidToolsMainWindow()
    uiMainWidget = Ui_MainWidget()
    winOsArgv = WinCommandEnCoding.getOsArgv()
    # single QApplication solution
    # http://blog.csdn.net/softdzf/article/details/6704187
    serverName = 'AndroidToolsServer'
    clientSocket = QLocalSocket()
    clientSocket.connectToServer(serverName)
    QSettingsUtil.init()
    # 如果连接成功, 表明server 已经存在,当前已经有实例在运行, 将参数发送给服务端
    if clientSocket.waitForConnected(500):
        # print u'连接成功 arg = ', winOsArgv
        stream = QtCore.QTextStream(clientSocket)
        # for i in range(0, len(winOsArgv)):
        #     stream << winOsArgv[i]
        # 对于打开终端来说,所携带参数为第1位(打开文件的地址),第0位为本执行程序地址
        if len(winOsArgv) > 1:
            stream << winOsArgv[1]
            stream.setCodec('UTF-8')
            stream.flush()
            clientSocket.waitForBytesWritten()
        # close client socket
        clientSocket.close()
        return app.quit()
    # 如果没有实例执行,创建服务器
    localServer = QLocalServer()
    # 一直监听端口
    localServer.listen(serverName)
    # create db
    createDb()
    try:
        uiMainWidget.setupUi(androidToolsMainWin, localServer, winOsArgv)
        androidToolsMainWin.show()
        sys.exit(app.exec_())
    finally:
        localServer.close()
Beispiel #8
0
def main():
    app = QtGui.QApplication(sys.argv)
    ffstoreMainWin = FFStoreMainWindow()

    # set skin styleSheet
    # SkinHelper().setStyle(app, ':/qss/white_style.qss')
    SkinHelper().setStyle(app, ':/qss/dark_style.qss')

    # single QApplication solution
    # http://blog.csdn.net/softdzf/article/details/6704187
    serverName = 'FFStoreManagerServer'
    clientSocket = QLocalSocket()
    clientSocket.connectToServer(serverName)
    # 如果连接成功, 表明server 已经存在,当前已经有实例在运行, 将参数发送给服务端
    if clientSocket.waitForConnected(500):
        # print u'连接成功 arg = ', winOsArgv
        stream = QtCore.QTextStream(clientSocket)
        # for i in range(0, len(winOsArgv)):
        #     stream << winOsArgv[i]
        # 对于打开终端来说,所携带参数为第1位(打开文件的地址),第0位为本执行程序地址
        # close client socket
        clientSocket.close()
        return app.quit()
    # 如果没有实例执行,创建服务器
    localServer = QLocalServer()
    # 一直监听端口
    localServer.listen(serverName)
    # 初始化全局变量
    GlobalVar.init()
    try:
        showWindowLogic = ShowWindowLogic(mainWindow=ffstoreMainWin,
                                          localServer=localServer)
        showWindowLogic.show()
        # uiMainWidget.setupUi(mainWindow=ffstoreMainWin, localServer=localServer)
        # ffstoreMainWin.show()
        sys.exit(app.exec_())
    finally:
        localServer.close()