Skip to content

Commit

Permalink
Permissions handling
Browse files Browse the repository at this point in the history
  • Loading branch information
chasvortex committed Nov 11, 2015
1 parent 517d2a2 commit e59cbba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions CGTGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import sys
from subprocess import PIPE, Popen
from threading import Thread

from contextlib import redirect_stdout
import io
stdout = io.StringIO()
from .IOparse import search as findfirstraw
import bpy
from queue import Queue, Empty
Expand Down Expand Up @@ -61,7 +63,7 @@ def execute(self, context):
if scn["donetraining"]:
scn["donetraining"] = False
wm = context.window_manager
self._timer = wm.event_timer_add(0.001, context.window)
self._timer = wm.event_timer_add(0.01, context.window)
wm.modal_handler_add(self)
self.train_graph = []
self.test_graph = []
Expand All @@ -75,8 +77,6 @@ def execute(self, context):
for node in context.selected_nodes:
if node.bl_idname == 'SolverNodeType':
error = False
output_dest = node.config_path
solverfile = 'train_%s.sh' % node.solvername
if error:
self.report({'ERROR'}, "No Solver Node added")
return {'FINISHED'}
Expand Down Expand Up @@ -163,7 +163,8 @@ def modal(self, context, event):
return {'FINISHED'}
dumpdata = [self.train_graph, self.test_graph, self.protodata, self.comment]
pickle.dump(dumpdata, open(os.path.join(self.tempdata, self.filename), 'wb'), protocol=2)
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
with redirect_stdout(stdout):
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
# ^^^ This is hacky but would have to be replaced by 50 lines of code to be 'proper'

## Quitting
Expand Down
3 changes: 2 additions & 1 deletion IOwriteprototxt.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,10 @@ def SolveFunction(context, operatorself=None):
scriptfile = open('train_%s.sh' % solvername, mode='w')
scriptfile.write(scriptstring)
scriptfile.close()
os.system("chmod 775 %s" % os.path.join(configpath,'train_%s.sh' % solvername))
print ('Finished solving tree')
non = (solution + '\nlayer {\n' + 'type: "Solver"\n' + solverstring + '\n}\n').split('\n')
return [[i + '\n' for i in non], Isize], configpath + 'train_%s.sh' % solvername
return [[i + '\n' for i in non], Isize], os.path.join(configpath,'train_%s.sh' % solvername)


class Solve(bpy.types.Operator):
Expand Down

0 comments on commit e59cbba

Please sign in to comment.