Wed, 27 Sep 2017 18:25:08 +0200
IMplemented the distributed code assist completions method.
196
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2017 Detlev Offenbach <detlev@die-offenbachs.de> |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the code assist client interface to rope. |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | from __future__ import unicode_literals |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | import sys |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | import os |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | sys.path.insert(0, os.path.dirname(__file__)) |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | if sys.version_info[0] >= 3: |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | path = os.path.join(os.path.dirname(__file__), 'rope_py3') |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | else: |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | path = os.path.join(os.path.dirname(__file__), 'rope_py2') |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | str = unicode # __IGNORE_WARNING__ |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | sys.path.insert(0, path) |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | import rope.base.libutils |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | import rope.contrib.codeassist |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | from JsonClient import JsonClient |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | class CodeAssistClient(JsonClient): |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | """ |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | Class implementing the code assist client interface to rope. |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
198
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
33 | PictureIDs = { |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
34 | "class": "?{0}".format(1), # Editor.ClassID |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
35 | "instance": "?{0}".format(1), # Editor.ClassID |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
36 | "function": "?{0}".format(4), # Editor.MethodID |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
37 | "module": "?{0}".format(7), # Editor.AttributeID |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
38 | "None": "", |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
39 | } |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
40 | # The various ID values are a copy of the ones found in the Editor |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
41 | # class in order to make this module/script independent from an |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
42 | # installed eric |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
43 | |
196
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | def __init__(self, host, port, idString, projectPath): |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | """ |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | Constructor |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | @param host ip address the background service is listening |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | @type str |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | @param port port of the background service |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | @type int |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | @param idString assigned client id to be sent back to the server in |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | order to identify the connection |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | @param str |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | @param projectPath path to the project |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | @type str |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | """ |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | super(CodeAssistClient, self).__init__(host, port, idString) |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | self.__methodMapping = { |
198
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
61 | "getCompletions": self.__getCompletions, |
196
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | } |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | self.__projectpath = projectPath |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | self.__project = rope.base.project.Project(self.__projectpath) |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | self.__project.validate(self.__project.root) |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | def handleCall(self, method, params): |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | """ |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | Public method to handle a method call from the server. |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | @param method requested method name |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | @type str |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | @param params dictionary with method specific parameters |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | @type dict |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | """ |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | self.__methodMapping[method](params) |
198
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
78 | |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
79 | def __handleRopeError(self, err): |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
80 | """ |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
81 | Private method to process a rope error. |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
82 | |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
83 | @param err rope exception object |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
84 | @type Exception |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
85 | @return dictionary containing the error information |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
86 | @rtype dict |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
87 | """ |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
88 | ropeError = str(type(err)).split()[-1] |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
89 | ropeError = ropeError[1:-2].split('.')[-1] |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
90 | errorDict = { |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
91 | "Error": ropeError, |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
92 | "ErrorString": str(err), |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
93 | } |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
94 | if ropeError == 'ModuleSyntaxError': |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
95 | errorDict["ErrorFile"] = err.filename |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
96 | errorDict["ErrorLine"] = err.lineno |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
97 | |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
98 | return errorDict |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
99 | |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
100 | def __getCompletions(self, params): |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
101 | """ |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
102 | Private method to calculate possible completions. |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
103 | |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
104 | @param params dictionary containing the method parameters |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
105 | @type dict |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
106 | """ |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
107 | filename = params["FileName"] |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
108 | source = params["Source"] |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
109 | offset = params["Offset"] |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
110 | maxfixes = params["MaxFixes"] |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
111 | |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
112 | if filename: |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
113 | resource = rope.base.libutils.path_to_resource( |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
114 | self.__project, filename) |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
115 | else: |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
116 | resource = None |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
117 | |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
118 | errorDict = {} |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
119 | completions = [] |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
120 | |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
121 | try: |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
122 | proposals = rope.contrib.codeassist.code_assist( |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
123 | self.__project, source, offset, resource, maxfixes=maxfixes) |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
124 | proposals = rope.contrib.codeassist.sorted_proposals(proposals) |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
125 | # TODO: extend this to include PictureIDs for protected and |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
126 | # private stuff (i.e. names starting with _ or __) |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
127 | completions = [proposal.name + self.PictureIDs[proposal.type] |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
128 | for proposal in proposals] |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
129 | except Exception as err: |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
130 | errorDict = self.__handleRopeError(err) |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
131 | |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
132 | result = { |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
133 | "Completions": completions, |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
134 | } |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
135 | result.update(errorDict) |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
136 | |
898d8b4187de
IMplemented the distributed code assist completions method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
196
diff
changeset
|
137 | self.sendJson("CompletionsResult", result) |
196
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | if __name__ == '__main__': |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | if len(sys.argv) != 5: |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | print('Host, port, id and project path parameters are missing. Abort.') |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
143 | sys.exit(1) |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | host, port, idString, projectPath = sys.argv[1:] |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | # Create a Qt4/5 application object in order to allow the processing of |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | # modules containing Qt stuff. |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | try: |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | from PyQt5.QtCore import QCoreApplication |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | except ImportError: |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | try: |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | from PyQt4.QtCore import QCoreApplication |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | except ImportError: |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | QCoreApplication = None |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | if QCoreApplication is not None: |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | app = QCoreApplication(sys.argv) |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | client = CodeAssistClient(host, int(port), idString, projectPath) |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | # Start the main loop |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | client.run() |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | sys.exit(0) |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | # |
26986d285975
Added the new code assist client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | # eflag: noqa = M801 |