-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCollaboration.py
105 lines (85 loc) · 3.52 KB
/
Collaboration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# ************************************************************************
# * Copyright (c) Stefan Troeger ([email protected]) 2019 *
# * *
# * This library is free software; you can redistribute it and/or *
# * modify it under the terms of the GNU Library General Public *
# * License as published by the Free Software Foundation; either *
# * version 2 of the License, or (at your option) any later version. *
# * *
# * This library is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this library; see the file COPYING.LIB. If not, *
# * write to the Free Software Foundation, Inc., 59 Temple Place, *
# * Suite 330, Boston, MA 02111-1307, USA *
# ************************************************************************
# check if we have installed all required modules
# ******************************************************
importfail = []
try:
import ocp
except Exception:
importfail.append("ocp")
pass
try:
import autobahn
except Exception:
importfail.append("autobahn")
pass
try:
import msgpack
except Exception:
importfail.append("msgpack")
pass
try:
import aiofiles
except Exception:
importfail.append("aiofiles")
pass
import Interface
if not importfail:
import code, traceback, signal
def debug(sig, frame):
"""Interrupt running process, and provide a python prompt for
interactive debugging."""
d={'_frame':frame} # Allow access to frame object.
d.update(frame.f_globals) # Unless shadowed by global
d.update(frame.f_locals)
i = code.InteractiveConsole(d)
message = "Signal received : entering python shell.\nTraceback:\n"
message += ''.join(traceback.format_stack(frame))
i.interact(message)
signal.signal(signal.SIGUSR1, debug) # Register handler
# txaio workaround
# ******************************************
import asyncio, txaio
if hasattr(txaio, "use_asyncio"):
txaio.use_asyncio()
else:
txaio.config.loop = asyncio.get_event_loop()
# setup all the collaboration infrastructure
# ******************************************
import os
from PySide import QtCore
from Manager import Manager
import Documents.Observer as Observer
from OCP import OCPConnection
#The Collaboration module provides functions to work on documents with others
#for now use simple global variables!
connection = OCPConnection()
manager = Manager(os.path.dirname(__file__), connection)
# bring the UI out of setup mode
Interface.uiWidget.setup(manager, connection)
#initialize the global FreeCAD document observer
Observer.initialize(manager)
# run the OCP framework!
connection.start()
if os.getenv('OCP_TEST_RUN', "0") == "1":
#connect to test server
import Test
tester = Test.Handler(connection, manager)
else:
Interface.uiWidget.setMissingPackages(importfail)