Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pyMKcam
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
pyMKcam
Commits
c38c1c2c
Commit
c38c1c2c
authored
Jan 26, 2012
by
Paul Bonser
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://pycam.git.sourceforge.net/gitroot/pycam/pycam
parents
7d21a483
09088718
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
25 deletions
+31
-25
STLImporter.py
pycam/Importers/STLImporter.py
+7
-1
GtkConsole.py
pycam/Plugins/GtkConsole.py
+17
-16
Models.py
pycam/Plugins/Models.py
+2
-3
Processes.py
pycam/Plugins/Processes.py
+0
-1
__init__.py
pycam/Plugins/__init__.py
+4
-3
xml_handling.py
pycam/Utils/xml_handling.py
+1
-1
No files found.
pycam/Importers/STLImporter.py
View file @
c38c1c2c
...
@@ -61,7 +61,8 @@ def ImportModel(filename, use_kdtree=True, callback=None, **kwargs):
...
@@ -61,7 +61,8 @@ def ImportModel(filename, use_kdtree=True, callback=None, **kwargs):
normal_conflict_warning_seen
=
False
normal_conflict_warning_seen
=
False
if
hasattr
(
filename
,
"read"
):
if
hasattr
(
filename
,
"read"
):
f
=
filename
# make sure that the input stream can seek and has ".len"
f
=
StringIO
.
StringIO
(
filename
.
read
())
# useful for later error messages
# useful for later error messages
filename
=
"input stream"
filename
=
"input stream"
else
:
else
:
...
@@ -70,6 +71,9 @@ def ImportModel(filename, use_kdtree=True, callback=None, **kwargs):
...
@@ -70,6 +71,9 @@ def ImportModel(filename, use_kdtree=True, callback=None, **kwargs):
# urllib.urlopen objects do not support "seek" - so we need to read
# urllib.urlopen objects do not support "seek" - so we need to read
# the whole file at once. This is ugly - anyone with a better idea?
# the whole file at once. This is ugly - anyone with a better idea?
f
=
StringIO
.
StringIO
(
url_file
.
read
())
f
=
StringIO
.
StringIO
(
url_file
.
read
())
# TODO: the above ".read" may be incomplete - this is ugly
# see http://patrakov.blogspot.com/2011/03/case-of-non-raised-exception.html
# and http://stackoverflow.com/questions/1824069/urllib2-not-retrieving-entire-http-response
url_file
.
close
()
url_file
.
close
()
except
IOError
,
err_msg
:
except
IOError
,
err_msg
:
log
.
error
(
"STLImporter: Failed to read file (
%
s):
%
s"
\
log
.
error
(
"STLImporter: Failed to read file (
%
s):
%
s"
\
...
@@ -93,6 +97,8 @@ def ImportModel(filename, use_kdtree=True, callback=None, **kwargs):
...
@@ -93,6 +97,8 @@ def ImportModel(filename, use_kdtree=True, callback=None, **kwargs):
f
.
seek
(
80
)
f
.
seek
(
80
)
numfacets
=
unpack
(
"<I"
,
f
.
read
(
4
))[
0
]
numfacets
=
unpack
(
"<I"
,
f
.
read
(
4
))[
0
]
binary
=
False
binary
=
False
log
.
debug
(
"STL import info:
%
s /
%
s /
%
s /
%
s"
%
\
(
f
.
len
,
numfacets
,
header
.
find
(
"solid"
),
header
.
find
(
"facet"
)))
if
f
.
len
==
(
84
+
50
*
numfacets
):
if
f
.
len
==
(
84
+
50
*
numfacets
):
binary
=
True
binary
=
True
...
...
pycam/Plugins/GtkConsole.py
View file @
c38c1c2c
...
@@ -55,24 +55,19 @@ class GtkConsole(pycam.Plugins.PluginBase):
...
@@ -55,24 +55,19 @@ class GtkConsole(pycam.Plugins.PluginBase):
self
.
_original_stdout
=
sys
.
stdout
self
.
_original_stdout
=
sys
.
stdout
self
.
_original_stdin
=
sys
.
stdin
self
.
_original_stdin
=
sys
.
stdin
self
.
_console_buffer
=
self
.
gui
.
get_object
(
"ConsoleViewBuffer"
)
self
.
_console_buffer
=
self
.
gui
.
get_object
(
"ConsoleViewBuffer"
)
class
ConsoleReplacement
(
object
):
# redirect the virtual console output to the window
def
__init__
(
self
):
sys
.
stdout
=
StringIO
.
StringIO
()
# clone sys.stdout
def
console_write
(
data
):
for
item
in
dir
(
sys
.
stdout
):
self
.
_console_buffer
.
insert
(
if
item
.
startswith
(
"_"
)
or
(
item
==
"write"
):
self
.
_console_buffer
.
get_end_iter
(),
data
)
continue
self
.
_console_buffer
.
place_cursor
(
child
=
getattr
(
sys
.
stdout
,
item
)
self
.
_console_buffer
.
get_end_iter
())
setattr
(
self
,
item
,
child
)
self
.
_console
.
write
=
console_write
def
write
(
self_obj
,
data
):
self
.
_console_buffer
.
insert
(
self
.
_console_buffer
.
get_end_iter
(),
data
)
self
.
_console_buffer
.
place_cursor
(
self
.
_console_buffer
.
get_end_iter
())
self
.
_original_stdout
.
write
(
data
)
sys
.
stdout
=
ConsoleReplacement
()
# make sure that we are never waiting for input (e.g. "help()")
# make sure that we are never waiting for input (e.g. "help()")
sys
.
stdin
=
StringIO
.
StringIO
()
sys
.
stdin
=
StringIO
.
StringIO
()
self
.
_console
.
write
=
sys
.
stdout
.
write
# multiprocessing has a bug regarding the handling of sys.stdin:
# see http://bugs.python.org/issue10174
sys
.
stdin
.
fileno
=
lambda
:
-
1
self
.
_clear_console
()
self
.
_clear_console
()
console_action
=
self
.
gui
.
get_object
(
"ToggleConsoleWindow"
)
console_action
=
self
.
gui
.
get_object
(
"ToggleConsoleWindow"
)
self
.
register_gtk_accelerator
(
"console"
,
console_action
,
None
,
self
.
register_gtk_accelerator
(
"console"
,
console_action
,
None
,
...
@@ -123,6 +118,12 @@ class GtkConsole(pycam.Plugins.PluginBase):
...
@@ -123,6 +118,12 @@ class GtkConsole(pycam.Plugins.PluginBase):
self
.
_console
.
write
(
text
+
os
.
linesep
)
self
.
_console
.
write
(
text
+
os
.
linesep
)
# execute command - check if it needs more input
# execute command - check if it needs more input
if
not
self
.
_console
.
push
(
text
):
if
not
self
.
_console
.
push
(
text
):
# append result to console view
sys
.
stdout
.
seek
(
0
)
for
line
in
sys
.
stdout
.
readlines
():
self
.
_console
.
write
(
line
)
# clear the buffer
sys
.
stdout
.
truncate
(
0
)
# scroll down console view to the end of the buffer
# scroll down console view to the end of the buffer
view
=
self
.
gui
.
get_object
(
"ConsoleView"
)
view
=
self
.
gui
.
get_object
(
"ConsoleView"
)
view
.
scroll_mark_onscreen
(
self
.
_console_buffer
.
get_insert
())
view
.
scroll_mark_onscreen
(
self
.
_console_buffer
.
get_insert
())
...
...
pycam/Plugins/Models.py
View file @
c38c1c2c
...
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
...
@@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
"""
import
uuid
# imported later (on demand)
# imported later (on demand)
#import gtk
#import gtk
...
@@ -97,9 +96,11 @@ class Models(pycam.Plugins.ListPluginBase):
...
@@ -97,9 +96,11 @@ class Models(pycam.Plugins.ListPluginBase):
self
.
core
.
register_namespace
(
"models"
,
self
.
core
.
register_namespace
(
"models"
,
pycam
.
Plugins
.
get_filter
(
self
))
pycam
.
Plugins
.
get_filter
(
self
))
self
.
core
.
set
(
"models"
,
self
)
self
.
core
.
set
(
"models"
,
self
)
self
.
register_state_item
(
"models"
,
self
)
return
True
return
True
def
teardown
(
self
):
def
teardown
(
self
):
self
.
clear_state_items
()
self
.
core
.
unregister_namespace
(
"models"
)
self
.
core
.
unregister_namespace
(
"models"
)
if
self
.
gui
:
if
self
.
gui
:
self
.
core
.
unregister_ui_section
(
"model_handling"
)
self
.
core
.
unregister_ui_section
(
"model_handling"
)
...
@@ -210,6 +211,4 @@ class ModelEntity(pycam.Plugins.ObjectWithAttributes):
...
@@ -210,6 +211,4 @@ class ModelEntity(pycam.Plugins.ObjectWithAttributes):
def
__init__
(
self
,
model
):
def
__init__
(
self
,
model
):
super
(
ModelEntity
,
self
)
.
__init__
(
"model"
)
super
(
ModelEntity
,
self
)
.
__init__
(
"model"
)
self
.
model
=
model
self
.
model
=
model
# this UUID is not connected with model.uuid
self
[
"uuid"
]
=
uuid
.
uuid4
()
pycam/Plugins/Processes.py
View file @
c38c1c2c
...
@@ -115,7 +115,6 @@ class Processes(pycam.Plugins.ListPluginBase):
...
@@ -115,7 +115,6 @@ class Processes(pycam.Plugins.ListPluginBase):
self
.
clear_state_items
()
self
.
clear_state_items
()
self
.
core
.
unregister_namespace
(
"processes"
)
self
.
core
.
unregister_namespace
(
"processes"
)
if
self
.
gui
:
if
self
.
gui
:
self
.
core
.
unregister_chain
(
"state_dump"
,
self
.
dump_state
)
self
.
core
.
unregister_ui
(
"main"
,
self
.
gui
.
get_object
(
"ProcessBox"
))
self
.
core
.
unregister_ui
(
"main"
,
self
.
gui
.
get_object
(
"ProcessBox"
))
self
.
core
.
unregister_ui_section
(
"process_path_parameters"
)
self
.
core
.
unregister_ui_section
(
"process_path_parameters"
)
self
.
core
.
unregister_ui
(
"process_parameters"
,
self
.
core
.
unregister_ui
(
"process_parameters"
,
...
...
pycam/Plugins/__init__.py
View file @
c38c1c2c
...
@@ -23,6 +23,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
...
@@ -23,6 +23,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
import
os
import
os
import
imp
import
imp
import
inspect
import
inspect
import
uuid
# TODO: load these modules only on demand
# TODO: load these modules only on demand
import
gtk
import
gtk
import
gobject
import
gobject
...
@@ -502,9 +503,9 @@ class ListPluginBase(PluginBase, list):
...
@@ -502,9 +503,9 @@ class ListPluginBase(PluginBase, list):
class
ObjectWithAttributes
(
dict
):
class
ObjectWithAttributes
(
dict
):
def
__init__
(
self
,
key
,
params
=
None
):
def
__init__
(
self
,
key
,
params
=
None
):
if
params
is
None
:
if
not
params
is
None
:
params
=
{}
self
.
update
(
params
)
self
.
update
(
params
)
self
[
"uuid"
]
=
uuid
.
uuid4
(
)
self
.
node_key
=
key
self
.
node_key
=
key
...
...
pycam/Utils/xml_handling.py
View file @
c38c1c2c
...
@@ -42,7 +42,7 @@ def get_xml(item, name=None):
...
@@ -42,7 +42,7 @@ def get_xml(item, name=None):
return
leaf
return
leaf
else
:
else
:
leaf
=
ET
.
Element
(
name
)
leaf
=
ET
.
Element
(
name
)
leaf
.
text
=
rep
r
(
item
)
leaf
.
text
=
st
r
(
item
)
return
leaf
return
leaf
def
parse_xml_dict
(
item
):
def
parse_xml_dict
(
item
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment