Hi guys,
I have a strange problem and I don't know where to start.
My Application is using the following action and when performed, it occasionally crashes with this Error:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
python2.7: ../../src/xcb_io.c:274: poll_for_event: Zusicherung »!xcb_xlib_threads_sequence_lost« nicht erfüllt.
I am not sure, but I feel like adding the listcomprehension testcuts = [tc for tc in test.testcuts if tc.enabled]
Camelot 13.04.13
made the problem occur more often.
Any pointers? Thanks.
Here is the Action code:
class ExportGCode(Action):
verbose_name='Export GCode'
#icon = Icon('tango/32x32/actions/mail-message-new.png')
tooltip = _('Create g-code for this series of testcuts. Only enabled testcuts are included in the export.')
def model_run(self, model_context):
test = model_context.get_object()
#only get enabled testcuts
testcuts = [tc for tc in test.testcuts if tc.enabled]
if len(testcuts)==0:
yield MessageBox( _('Nothing to export. Please create some testcuts first.'), icon=QMessageBox.Information, standard_buttons=QMessageBox.Ok)
else:
select_output_file = SelectFile('GCode files (*.nc *.txt *.gc)')
select_output_file.existing=False
filenames = yield select_output_file
#check if we got a filename
if len(filenames) > 0:
filename = filenames[0]
yield UpdateProgress( text = _('Exporting GCode') )
#define variables that can be used in gcode here
context = dict(
#Machine
machine_name = test.machine.name,
machine_safe_z = test.machine.safe_z,
#Tool
tool_name = test.tool.name,
tool_type = test.tool.type,
tool_material = test.tool.tool_material,
tool_coating = test.tool.coating,
tool_diameter = test.tool.diameter,
tool_flutes = test.tool.flutes,
tool_cutting_length = test.tool.cutting_length,
tool_full_lenght = test.tool.full_length,
tool_cutting_angle = test.tool.cutting_angle,
tool_Smax = test.tool.Smax,
tool_number = test.tool.tool_number,
tool_manufacturer = test.tool.manufacturer,
#Material
material_name = test.material.name,
material_type = test.material.type,
material_recommended_VCC = test.material.recommended_VCC,
material_machinability = test.material.machinability,
material_hardness = test.material.hardness,
#Test
test_name = test.name,
test_number_of_cuts = len(testcuts), #use the actual value, not the set value from the test dialog
test_start_S = test.start_S,
test_S_increment = test.S_increment,
test_start_CPT = test.start_CPT,
test_CPT_increment = test.CPT_increment,
test_Fp_percent = test.Fp_percent,
test_Ap = test.Ap,
test_Ap_increment = test.Ap_increment,
test_Ae = test.Ae,
test_Ae_increment = test.Ae_increment,
test_coolant = test.coolant,
test_comment = text_from_richtext(test.comment))
output_gcode = u''
templates = dict(
header = u'(g-code created by Chips - tool test and management suite)\n\n',
machine_precode = text_from_richtext(test.machine.precode)+u"\n",
machine_postcode = text_from_richtext(test.machine.postcode)+u"\n",
pre_cut_code = text_from_richtext(test.pre_cut_gcode)+u"\n",
cut_code = text_from_richtext(test.cut_gcode)+u"\n",
post_cut_code = text_from_richtext(test.post_cut_gcode)+u"\n",
)
e = Environment(loader=DictLoader(templates), autoescape=True,trim_blocks=True)
#Processing Gcode
#process header
t = e.get_template('header')
output_gcode += unicode(t.render(context))
#process machine_precode
t = e.get_template('machine_precode')
output_gcode += t.render(context)
for cut in testcuts:
#create new context dict to represent variables of a sigle cut
cut_context=dict(
cut_number = cut.cut_number,
cut_S = cut.S,
cut_F = cut.F,
cut_Fp = cut.Fp,
cut_Ap = cut.Ap,
cut_Ae = cut.Ae,
cut_CPT = cut.CPT,
cut_MRR = cut.MRR
)
#join cut_context with context dictionary to get access to all variables
cut_context = dict(cut_context.items() + context.items())
t = e.get_template('pre_cut_code')
output_gcode += t.render(cut_context)
t = e.get_template('cut_code')
output_gcode += t.render(cut_context)
t = e.get_template('post_cut_code')
output_gcode += t.render(cut_context)
#process machine_postcode
t = e.get_template('machine_postcode')
output_gcode += t.render(context)
#write the whole thing to a textfile
try:
f = codecs.open(filename,"w", "utf-8")
f.write(output_gcode)
f.close()
except Exception, e:
yield MessageBox( _('Could not write file: %s' %e), icon=QMessageBox.Warning, standard_buttons=QMessageBox.Ok)Code hier eingeben...