-
Notifications
You must be signed in to change notification settings - Fork 1
/
skeinforge-0005-twitterbot-0.1.patch
664 lines (652 loc) · 41.7 KB
/
skeinforge-0005-twitterbot-0.1.patch
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
diff -rcN --exclude=.DS_STORE skeinforge-0005/documentation/skeinforge_tools.export.html skeinforge-0005_tb/documentation/skeinforge_tools.export.html
*** skeinforge-0005/documentation/skeinforge_tools.export.html 2009-11-03 09:20:17.000000000 -0800
--- skeinforge-0005_tb/documentation/skeinforge_tools.export.html 2009-11-04 09:16:05.000000000 -0800
***************
*** 1,14 ****
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
! <html><head><title>Python: module skeinforge_tools.export</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
! <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="skeinforge_tools.html"><font color="#ffffff">skeinforge_tools</font></a>.export</strong></big></big> ($Date: 2008/21/04 $)</font></td
><td align=right valign=bottom
! ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/export.py">/home/enrique/Desktop/backup/babbleold/script/reprap/pyRepRap/skeinforge_tools/export.py</a></font></td></tr></table>
<p><tt>Export is a script to pick an export plugin and optionally print the output to a file.<br>
<br>
The default 'Activate Export' checkbox is on. When it is on, the functions described below will work, when it is off, the functions<br>
--- 1,14 ----
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
! <html><head><title>Python: module export</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
! <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>export</strong></big></big> ($Date: 2008/21/04 $)</font></td
><td align=right valign=bottom
! ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/Applications/MakerBot/SkeinFox 1.0.app/Contents/Resources/skeinforge-0005/skeinforge_tools/export.py">/Applications/MakerBot/SkeinFox 1.0.app/Contents/Resources/skeinforge-0005/skeinforge_tools/export.py</a></font></td></tr></table>
<p><tt>Export is a script to pick an export plugin and optionally print the output to a file.<br>
<br>
The default 'Activate Export' checkbox is on. When it is on, the functions described below will work, when it is off, the functions<br>
***************
*** 25,31 ****
the gcode is generated by skeinforge. If the "Delete Comments" checkbox is true, export will delete the comments. The M110<br>
gcode and the comments are not necessary to run a fabricator.<br>
<br>
! When export is exporting the code, if there is a file replace.csv, it will replace the word in the first column be its replacement in<br>
the second column. There is an example file replace_example.csv to demonstrate the comma separated format, which can be<br>
edited in a text editor or a spreadsheet.<br>
<br>
--- 25,31 ----
the gcode is generated by skeinforge. If the "Delete Comments" checkbox is true, export will delete the comments. The M110<br>
gcode and the comments are not necessary to run a fabricator.<br>
<br>
! When export is exporting the code, if there is a file replace.csv, it will replace the word in the first column by its replacement in<br>
the second column. There is an example file replace_example.csv to demonstrate the comma separated format, which can be<br>
edited in a text editor or a spreadsheet.<br>
<br>
***************
*** 36,42 ****
<br>
The following examples export the files Screw Holder Bottom.stl. The examples are run in a terminal in the folder which contains<br>
Screw Holder Bottom.stl & export.py. The function writeOutput checks to see if the text has been exported, if not they call<br>
! getUnpauseChainGcode in unpause.py to unpause the text; once they have the unpaused text, then it exports.<br>
<br>
<br>
> python export.py<br>
--- 36,42 ----
<br>
The following examples export the files Screw Holder Bottom.stl. The examples are run in a terminal in the folder which contains<br>
Screw Holder Bottom.stl & export.py. The function writeOutput checks to see if the text has been exported, if not they call<br>
! getTwitterbotChainGcode in twitterbot.py to twitterbot the text; once they have the twitterbotted text, then it exports.<br>
<br>
<br>
> python export.py<br>
***************
*** 77,83 ****
<a href="skeinforge_tools.skeinforge_utilities.preferences.html">skeinforge_tools.skeinforge_utilities.preferences</a><br>
<a href="sys.html">sys</a><br>
<a href="time.html">time</a><br>
! </td><td width="25%" valign=top><a href="skeinforge_tools.unpause.html">skeinforge_tools.unpause</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
--- 77,83 ----
<a href="skeinforge_tools.skeinforge_utilities.preferences.html">skeinforge_tools.skeinforge_utilities.preferences</a><br>
<a href="sys.html">sys</a><br>
<a href="time.html">time</a><br>
! </td><td width="25%" valign=top><a href="skeinforge_tools.twitterbot.html">skeinforge_tools.twitterbot</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
***************
*** 86,93 ****
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
! <dt><font face="helvetica, arial"><a href="skeinforge_tools.export.html#ExportPreferences">ExportPreferences</a>
! </font></dt><dt><font face="helvetica, arial"><a href="skeinforge_tools.export.html#ExportSkein">ExportSkein</a>
</font></dt></dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
--- 86,93 ----
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
! <dt><font face="helvetica, arial"><a href="export.html#ExportPreferences">ExportPreferences</a>
! </font></dt><dt><font face="helvetica, arial"><a href="export.html#ExportSkein">ExportSkein</a>
</font></dt></dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
diff -rcN --exclude=.DS_STORE skeinforge-0005/documentation/skeinforge_tools.twitterbot.html skeinforge-0005_tb/documentation/skeinforge_tools.twitterbot.html
*** skeinforge-0005/documentation/skeinforge_tools.twitterbot.html 1969-12-31 16:00:00.000000000 -0800
--- skeinforge-0005_tb/documentation/skeinforge_tools.twitterbot.html 2009-11-04 09:16:06.000000000 -0800
***************
*** 0 ****
--- 1,187 ----
+
+ <!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+ <html><head><title>Python: module twitterbot</title>
+ </head><body bgcolor="#f0f0f8">
+
+ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
+ <tr bgcolor="#7799ee">
+ <td valign=bottom> <br>
+ <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>twitterbot</strong></big></big> (version $0.1 $, $Date: 2009/01/11 $)</font></td
+ ><td align=right valign=bottom
+ ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/Applications/MakerBot/SkeinFox 1.0.app/Contents/Resources/skeinforge-0005/skeinforge_tools/twitterbot.py">/Applications/MakerBot/SkeinFox 1.0.app/Contents/Resources/skeinforge-0005/skeinforge_tools/twitterbot.py</a></font></td></tr></table>
+ <p><tt>Twitterbot is a tool to insert Twitterbot M-code into a gcode file so that a modified version of ReplicatorG can tweet printing progress to a Twitter account.<br>
+ Rick Pollack wrote the code to enable ReplicatorG to call the Twitter API via the twitter4j library.<br>
+ You can get the necessary files to modify ReplicatorG here: <a href="http://makerbot.googlegroups.com/web/TwitterBot+Src+Update+1.zip">http://makerbot.googlegroups.com/web/TwitterBot+Src+Update+1.zip</a><br>
+ This tool has only been tested with Skeinforge-0005 and ReplicatorG-0009.<br>
+ <br>
+ The default 'Activate Twitterbot' checkbox is off. When it is on, the functions described below will be called. When it is off, the functions<br>
+ will not be called.<br>
+ <br>
+ The tool's Preferences are:<br>
+ <br>
+ 'Activate Twitterbot' - Check this to enable the tool. Default is un-checked or off.<br>
+ 'Twitter Username' - Username for the Twitter account. Default is empty.<br>
+ 'Twitter Password' - Password for the Twitter account. Default is empty.<br>
+ 'Hashtag(s)' - Space-delimited hashtags to append to each tweet. Default is #MakerBot #Twitterbot.<br>
+ <br>
+ Since your Twitter credentials are written to the generated gcode file, either remove them before sharing the file, or re-run with 'Activate Twitterbot' off. <br>
+ <br>
+ IMPORTANT! If you forget to remove your credentials after sharing a file, change your Twitter password immediately!<br>
+ <br>
+ NOTE: For tall, and therefore many layered source files, it is quite possible to exceed the Twitter rate limit with a single print.<br>
+ For more information see: <a href="http://apiwiki.twitter.com/Rate-limiting">http://apiwiki.twitter.com/Rate-limiting</a><br>
+ This may be addressed in a future version of twitterbot.<br>
+ <br>
+ To run twitterbot, in a shell type:<br>
+ > python twitterbot.py<br>
+ <br>
+ The following examples twitterbot - add Twitter M-code to - the files Screw Holder Bottom.gcode & Screw Holder Bottom.stl. The examples are run in a terminal in the<br>
+ folder which contains Screw Holder Bottom.gcode, Screw Holder Bottom.stl and twitterbot.py. The twitterbot function will twitterbot if 'Activate Twitterbot' is true,<br>
+ which can be set in the dialog or by changing the preferences file 'twitterbot.csv' in the '.skeinforge' folder in your home directory<br>
+ with a text editor or a spreadsheet program set to separate tabs. The functions writeOutput and getTwitterbotChainGcode check<br>
+ to see if the text has been twitterbotted, if not they call getUnpauseChainGcode in unpause.py to unpause the text; once they have the<br>
+ unpaused text, then they twitterbot.<br>
+ <br>
+ <br>
+ > python twitterbot.py<br>
+ This brings up the dialog, after clicking 'Twitterbot', the following is printed:<br>
+ File Screw Holder Bottom.stl is being chain twitterbotted.<br>
+ The twitterbotted file is saved as Screw Holder Bottom_twitterbot.gcode<br>
+ <br>
+ <br>
+ > python twitterbot.py Screw Holder Bottom.stl<br>
+ File Screw Holder Bottom.stl is being chain twitterbotted.<br>
+ The twitterbotted file is saved as Screw Holder Bottom_twitterbot.gcode<br>
+ <br>
+ <br>
+ > python<br>
+ Python 2.5.1 (r251:54863, Jun 17 2009, 20:37:34) <br>
+ [GCC 4.0.1 (Apple Inc. build 5465)] on darwin<br>
+ Type "help", "copyright", "credits" or "license" for more information.<br>
+ >>> import twitterbot<br>
+ >>> twitterbot.<a href="#-main">main</a>()<br>
+ This brings up the twitterbot dialog.<br>
+ <br>
+ <br>
+ >>> twitterbot.<a href="#-writeOutput">writeOutput</a>()<br>
+ Screw Holder Bottom.stl<br>
+ File Screw Holder Bottom.stl is being chain twitterbotted.<br>
+ The twitterbotted file is saved as Screw Holder Bottom_twitterbot.gcode<br>
+ <br>
+ <br>
+ >>> twitter.<a href="#-getTwitterbotGcode">getTwitterbotGcode</a>("<br>
+ ( GCode generated by May 8, 2008 carve.py )<br>
+ ( Extruder Initialization )<br>
+ ..<br>
+ many lines of gcode<br>
+ ..<br>
+ ")<br>
+ <br>
+ <br>
+ >>> twitterbot.<a href="#-getTwitterbotChainGcode">getTwitterbotChainGcode</a>("<br>
+ ( GCode generated by May 8, 2008 carve.py )<br>
+ ( Extruder Initialization )<br>
+ ..<br>
+ many lines of gcode<br>
+ ..<br>
+ ")</tt></p>
+ <p>
+ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+ <tr bgcolor="#aa55cc">
+ <td colspan=3 valign=bottom> <br>
+ <font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
+
+ <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
+ <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="__init__.html">__init__</a><br>
+ <a href="skeinforge_tools.analyze.html">skeinforge_tools.analyze</a><br>
+ <a href="cStringIO.html">cStringIO</a><br>
+ </td><td width="25%" valign=top><a href="skeinforge_tools.skeinforge_utilities.gcodec.html">skeinforge_tools.skeinforge_utilities.gcodec</a><br>
+ <a href="skeinforge_tools.skeinforge_utilities.interpret.html">skeinforge_tools.skeinforge_utilities.interpret</a><br>
+ <a href="os.html">os</a><br>
+ </td><td width="25%" valign=top><a href="skeinforge_tools.polyfile.html">skeinforge_tools.polyfile</a><br>
+ <a href="skeinforge_tools.skeinforge_utilities.preferences.html">skeinforge_tools.skeinforge_utilities.preferences</a><br>
+ <a href="sys.html">sys</a><br>
+ </td><td width="25%" valign=top><a href="time.html">time</a><br>
+ <a href="skeinforge_tools.unpause.html">skeinforge_tools.unpause</a><br>
+ </td></tr></table></td></tr></table><p>
+ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+ <tr bgcolor="#ee77aa">
+ <td colspan=3 valign=bottom> <br>
+ <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
+
+ <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
+ <td width="100%"><dl>
+ <dt><font face="helvetica, arial"><a href="twitterbot.html#TwitterbotPreferences">TwitterbotPreferences</a>
+ </font></dt><dt><font face="helvetica, arial"><a href="twitterbot.html#TwitterbotSkein">TwitterbotSkein</a>
+ </font></dt></dl>
+ <p>
+ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+ <tr bgcolor="#ffc8d8">
+ <td colspan=3 valign=bottom> <br>
+ <font color="#000000" face="helvetica, arial"><a name="TwitterbotPreferences">class <strong>TwitterbotPreferences</strong></a></font></td></tr>
+
+ <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
+ <td colspan=2><tt>A class to handle the twitterbot preferences.<br> </tt></td></tr>
+ <tr><td> </td>
+ <td width="100%">Methods defined here:<br>
+ <dl><dt><a name="TwitterbotPreferences-__init__"><strong>__init__</strong></a>(self)</dt><dd><tt>Set the default preferences, execute title & preferences fileName.</tt></dd></dl>
+
+ <dl><dt><a name="TwitterbotPreferences-execute"><strong>execute</strong></a>(self)</dt><dd><tt>Twitterbot button has been clicked.</tt></dd></dl>
+
+ </td></tr></table> <p>
+ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+ <tr bgcolor="#ffc8d8">
+ <td colspan=3 valign=bottom> <br>
+ <font color="#000000" face="helvetica, arial"><a name="TwitterbotSkein">class <strong>TwitterbotSkein</strong></a></font></td></tr>
+
+ <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
+ <td colspan=2><tt>A class to insert Twitter M-code into a gcode file.<br> </tt></td></tr>
+ <tr><td> </td>
+ <td width="100%">Methods defined here:<br>
+ <dl><dt><a name="TwitterbotSkein-__init__"><strong>__init__</strong></a>(self)</dt></dl>
+
+ <dl><dt><a name="TwitterbotSkein-addLine"><strong>addLine</strong></a>(self, line)</dt><dd><tt>Add a line of text and a newline to the output.</tt></dd></dl>
+
+ <dl><dt><a name="TwitterbotSkein-createMessage"><strong>createMessage</strong></a>(self, messageText)</dt><dd><tt>Add the message M-Code to a string and return it.</tt></dd></dl>
+
+ <dl><dt><a name="TwitterbotSkein-getSavedGCodeFileName"><strong>getSavedGCodeFileName</strong></a>(self)</dt><dd><tt>Get original filename and change to the skeinforged one, i.e., ???_export.gcode.</tt></dd></dl>
+
+ <dl><dt><a name="TwitterbotSkein-parseGcode"><strong>parseGcode</strong></a>(self, gcodeText, twitterbotPreferences)</dt><dd><tt>Parse gcode text and store the twitterbot gcode.</tt></dd></dl>
+
+ <dl><dt><a name="TwitterbotSkein-parseInitialization"><strong>parseInitialization</strong></a>(self, twitterbotPreferences)</dt><dd><tt>Parse gcode initialization and store the parameters.</tt></dd></dl>
+
+ <dl><dt><a name="TwitterbotSkein-parseLine"><strong>parseLine</strong></a>(self, line)</dt><dd><tt>Parse a gcode line and add Twitter M-code to it.</tt></dd></dl>
+
+ <dl><dt><a name="TwitterbotSkein-setGcodeFilePathAndName"><strong>setGcodeFilePathAndName</strong></a>(self, gcodeFilePathAndName)</dt><dd><tt>Save path and filename of gcode file to this class. Called by <a href="#-getTwitterbotGcode">getTwitterbotGcode</a>()</tt></dd></dl>
+
+ </td></tr></table></td></tr></table><p>
+ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+ <tr bgcolor="#eeaa77">
+ <td colspan=3 valign=bottom> <br>
+ <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
+
+ <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
+ <td width="100%"><dl><dt><a name="-getTwitterbotChainGcode"><strong>getTwitterbotChainGcode</strong></a>(fileName, gcodeText, twitterbotPreferences<font color="#909090">=None</font>)</dt><dd><tt>Add Twitterbot M-code to a gcode text. Chain twitterbot the gcode if it is not already twitterbotted.</tt></dd></dl>
+ <dl><dt><a name="-getTwitterbotGcode"><strong>getTwitterbotGcode</strong></a>(gcodeText, fileName, twitterbotPreferences<font color="#909090">=None</font>)</dt><dd><tt>Add Twitterbot M-code to a gcode text.</tt></dd></dl>
+ <dl><dt><a name="-main"><strong>main</strong></a>(hashtable<font color="#909090">=None</font>)</dt><dd><tt>Display the Twitterbot dialog.</tt></dd></dl>
+ <dl><dt><a name="-writeOutput"><strong>writeOutput</strong></a>(fileName<font color="#909090">=''</font>)</dt><dd><tt>Twitterbot a gcode file. Chain twitterbot the gcode if it is not already twitterbotted. If no fileName is specified, twitterbot the first unmodified gcode file in this folder.</tt></dd></dl>
+ </td></tr></table><p>
+ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+ <tr bgcolor="#55aa55">
+ <td colspan=3 valign=bottom> <br>
+ <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
+
+ <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
+ <td width="100%"><strong>__author__</strong> = 'Miles Lightwood (m@teamteamusa.com)'<br>
+ <strong>__date__</strong> = '$Date: 2009/01/11 $'<br>
+ <strong>__license__</strong> = 'GPL 3.0'<br>
+ <strong>__version__</strong> = '$0.1 $'<br>
+ <strong>absolute_import</strong> = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)</td></tr></table><p>
+ <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+ <tr bgcolor="#7799ee">
+ <td colspan=3 valign=bottom> <br>
+ <font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
+
+ <tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
+ <td width="100%">Miles Lightwood (m@teamteamusa.com)</td></tr></table>
+ </body></html>
\ No newline at end of file
diff -rcN --exclude=.DS_STORE skeinforge-0005/skeinforge.py skeinforge-0005_tb/skeinforge.py
*** skeinforge-0005/skeinforge.py 2009-11-03 09:20:17.000000000 -0800
--- skeinforge-0005_tb/skeinforge.py 2009-11-01 22:41:51.000000000 -0800
***************
*** 266,272 ****
def writeOutput( fileName = '' ):
"Skeinforge a gcode file. If no fileName is specified, skeinforge the first gcode file in this folder that is not modified."
skeinforgePluginFilenames = getSkeinforgeToolFilenames()
! toolNames = 'export unpause fillet oozebane wipe hop stretch clip comb tower raft speed multiply fill inset carve'.split()
for toolName in toolNames:
for skeinforgePluginFilename in skeinforgePluginFilenames:
if skeinforgePluginFilename == toolName:
--- 266,272 ----
def writeOutput( fileName = '' ):
"Skeinforge a gcode file. If no fileName is specified, skeinforge the first gcode file in this folder that is not modified."
skeinforgePluginFilenames = getSkeinforgeToolFilenames()
! toolNames = 'export twitterbot unpause fillet oozebane wipe hop stretch clip comb tower raft speed multiply fill inset carve'.split()
for toolName in toolNames:
for skeinforgePluginFilename in skeinforgePluginFilenames:
if skeinforgePluginFilename == toolName:
diff -rcN --exclude=.DS_STORE skeinforge-0005/skeinforge_tools/export.py skeinforge-0005_tb/skeinforge_tools/export.py
*** skeinforge-0005/skeinforge_tools/export.py 2009-11-03 09:20:17.000000000 -0800
--- skeinforge-0005_tb/skeinforge_tools/export.py 2009-11-04 22:46:53.000000000 -0800
***************
*** 26,32 ****
The following examples export the files Screw Holder Bottom.stl. The examples are run in a terminal in the folder which contains
Screw Holder Bottom.stl & export.py. The function writeOutput checks to see if the text has been exported, if not they call
! getUnpauseChainGcode in unpause.py to unpause the text; once they have the unpaused text, then it exports.
> python export.py
--- 26,32 ----
The following examples export the files Screw Holder Bottom.stl. The examples are run in a terminal in the folder which contains
Screw Holder Bottom.stl & export.py. The function writeOutput checks to see if the text has been exported, if not they call
! getTwitterbotChainGcode in twitterbot.py to twitterbot the text; once they have the twitterbotted text, then it exports.
> python export.py
***************
*** 62,68 ****
from skeinforge_tools import analyze
from skeinforge_tools.skeinforge_utilities import interpret
from skeinforge_tools import polyfile
! from skeinforge_tools import unpause
import cStringIO
import os
import sys
--- 62,68 ----
from skeinforge_tools import analyze
from skeinforge_tools.skeinforge_utilities import interpret
from skeinforge_tools import polyfile
! from skeinforge_tools import twitterbot
import cStringIO
import os
import sys
***************
*** 125,132 ****
print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain exported.' )
suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_export.' + exportPreferences.fileExtension.value
gcodeText = gcodec.getGcodeFileText( fileName, '' )
! if not gcodec.isProcedureDone( gcodeText, 'unpause' ):
! gcodeText = unpause.getUnpauseChainGcode( fileName, gcodeText )
if gcodeText == '':
return
analyze.writeOutput( suffixFilename, gcodeText )
--- 125,132 ----
print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain exported.' )
suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_export.' + exportPreferences.fileExtension.value
gcodeText = gcodec.getGcodeFileText( fileName, '' )
! if not gcodec.isProcedureDone( gcodeText, 'twitterbot' ):
! gcodeText = twitterbot.getTwitterbotChainGcode( fileName, gcodeText )
if gcodeText == '':
return
analyze.writeOutput( suffixFilename, gcodeText )
diff -rcN --exclude=.DS_STORE skeinforge-0005/skeinforge_tools/twitterbot.py skeinforge-0005_tb/skeinforge_tools/twitterbot.py
*** skeinforge-0005/skeinforge_tools/twitterbot.py 1969-12-31 16:00:00.000000000 -0800
--- skeinforge-0005_tb/skeinforge_tools/twitterbot.py 2009-11-09 23:32:39.000000000 -0800
***************
*** 0 ****
--- 1,283 ----
+ """
+ Twitterbot is a tool to insert Twitterbot M-code into a gcode file so that a modified version of ReplicatorG can tweet printing progress to a Twitter account.
+ Rick Pollack wrote the code to enable ReplicatorG to call the Twitter API via the twitter4j library.
+ You can get the necessary files to modify ReplicatorG here: http://makerbot.googlegroups.com/web/TwitterBot+Src+Update+1.zip
+ This tool has been tested with Skeinforge-0005, Skeinforge-0006, and ReplicatorG-0009.
+
+ The default 'Activate Twitterbot' checkbox is off. When it is on, the functions described below will be called. When it is off, the functions
+ will not be called.
+
+ The tool's Preferences are:
+
+ 'Activate Twitterbot' - Check this to enable the tool. Default is un-checked or off.
+ 'Twitter Username' - Username for the Twitter account. Default is empty.
+ 'Twitter Password' - Password for the Twitter account. Default is empty.
+ 'Layers Between Tweets' - The number of layers between each tweet, e.g., 3 means tweet each 3rd layer. Default is 10.
+ 'Hashtag(s)' - Space-delimited hashtags to append to each tweet. Default is #MakerBot #Twitterbot.
+
+ Since your Twitter credentials are written to the generated gcode file, either remove them before sharing the file, or re-run with 'Activate Twitterbot' off.
+
+ IMPORTANT! If you forget to remove your credentials after sharing a file, change your Twitter password immediately!
+
+ NOTE: For tall, and therefore many layered source files, it is quite possible to exceed the Twitter rate limit with a single print.
+ For more information see: http://apiwiki.twitter.com/Rate-limiting
+ This may be addressed in a future version of twitterbot.
+
+ To run twitterbot, in a shell type:
+ > python twitterbot.py
+
+ The following examples twitterbot - add Twitter M-code to - the files Screw Holder Bottom.gcode & Screw Holder Bottom.stl. The examples are run in a terminal in the
+ folder which contains Screw Holder Bottom.gcode, Screw Holder Bottom.stl and twitterbot.py. The twitterbot function will twitterbot if 'Activate Twitterbot' is true,
+ which can be set in the dialog or by changing the preferences file 'twitterbot.csv' in the '.skeinforge' folder in your home directory
+ with a text editor or a spreadsheet program set to separate tabs. The functions writeOutput and getTwitterbotChainGcode check
+ to see if the text has been twitterbotted, if not they call getUnpauseChainGcode in unpause.py to unpause the text; once they have the
+ unpaused text, then they twitterbot.
+
+
+ > python twitterbot.py
+ This brings up the dialog, after clicking 'Twitterbot', the following is printed:
+ File Screw Holder Bottom.stl is being chain twitterbotted.
+ The twitterbotted file is saved as Screw Holder Bottom_twitterbot.gcode
+
+
+ > python twitterbot.py Screw Holder Bottom.stl
+ File Screw Holder Bottom.stl is being chain twitterbotted.
+ The twitterbotted file is saved as Screw Holder Bottom_twitterbot.gcode
+
+
+ > python
+ Python 2.5.1 (r251:54863, Jun 17 2009, 20:37:34)
+ [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
+ Type "help", "copyright", "credits" or "license" for more information.
+ >>> import twitterbot
+ >>> twitterbot.main()
+ This brings up the twitterbot dialog.
+
+
+ >>> twitterbot.writeOutput()
+ Screw Holder Bottom.stl
+ File Screw Holder Bottom.stl is being chain twitterbotted.
+ The twitterbotted file is saved as Screw Holder Bottom_twitterbot.gcode
+
+
+ >>> twitter.getTwitterbotGcode("
+ ( GCode generated by May 8, 2008 carve.py )
+ ( Extruder Initialization )
+ ..
+ many lines of gcode
+ ..
+ ")
+
+
+ >>> twitterbot.getTwitterbotChainGcode("
+ ( GCode generated by May 8, 2008 carve.py )
+ ( Extruder Initialization )
+ ..
+ many lines of gcode
+ ..
+ ")
+
+ """
+
+ #TODO:
+ # * Make Starting, Printing layer, and Finishing, messages configurable, i.e., add them to Preferences. Need to figure out string replacing in Python first
+ # * Add quips to Preferences so humorous tweets can be sent randomly or when certain events occur, e.g., What's that smell?, Copper is the new black!, This print sure is ugly!, Only at layer 5? I need a rest!
+ # * To reduce the number of tweets per print, calculate the number of lines in the file (maybe G lines instead) and print a configurable percentage (dropdown menu?),
+ # e.g., 25 means tweet only when every 25% of the print is printing. 25 would result in 6 tweets (1 start tweet + 4 progress tweets + 1 end tweet)
+ # * If Layers Between Tweets is less than 0 change to default, i.e., 5, and save to Preferencs file [twitterbot.csv]
+
+ from __future__ import absolute_import
+ #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
+ import __init__
+
+ #from skeinforge_tools.skeinforge_utilities import euclidean
+ from skeinforge_tools.skeinforge_utilities import gcodec
+ from skeinforge_tools.skeinforge_utilities import preferences
+ from skeinforge_tools import analyze
+ from skeinforge_tools import unpause
+ from skeinforge_tools.skeinforge_utilities import interpret
+ from skeinforge_tools import polyfile
+ import cStringIO
+ #import math
+ import sys
+ import os
+ import time
+
+
+ __author__ = "Miles Lightwood (m@teamteamusa.com)"
+ __date__ = "$Date: 2009/08/11 $"
+ __version__ = "$0.2 $"
+ __license__ = "GPL 3.0"
+
+ def getTwitterbotChainGcode( fileName, gcodeText, twitterbotPreferences = None ):
+ "Add Twitterbot M-code to a gcode text. Chain twitterbot the gcode if it is not already twitterbotted."
+ gcodeText = gcodec.getGcodeFileText( fileName, gcodeText )
+ if not gcodec.isProcedureDone( gcodeText, 'unpause' ):
+ gcodeText = unpause.getUnpauseChainGcode( fileName, gcodeText )
+ print( 'getTwitterbotChainGcode(fileName): ' + fileName )
+ return getTwitterbotGcode( gcodeText, fileName, twitterbotPreferences )
+
+ def getTwitterbotGcode( gcodeText, fileName, twitterbotPreferences = None ):
+ "Add Twitterbot M-code to a gcode text."
+ if gcodeText == '':
+ return ''
+ if gcodec.isProcedureDone( gcodeText, 'twitterbot' ):
+ return gcodeText
+ if twitterbotPreferences == None:
+ twitterbotPreferences = TwitterbotPreferences()
+ preferences.readPreferences( twitterbotPreferences )
+ if not twitterbotPreferences.activateTwitterbot.value:
+ return gcodeText
+ skein = TwitterbotSkein()
+ skein.setGcodeFilePathAndName( fileName )
+ skein.parseGcode( gcodeText, twitterbotPreferences )
+ return skein.output.getvalue()
+
+ def writeOutput( fileName = '' ):
+ "Twitterbot a gcode file. Chain twitterbot the gcode if it is not already twitterbotted. If no fileName is specified, twitterbot the first unmodified gcode file in this folder."
+ if fileName == '':
+ unmodified = interpret.getGNUTranslatorFilesUnmodified()
+ if len( unmodified ) == 0:
+ print( "There are no unmodified gcode files in this folder." )
+ return
+ fileName = unmodified[ 0 ]
+ twitterbotPreferences = TwitterbotPreferences()
+ preferences.readPreferences( twitterbotPreferences )
+ startTime = time.time()
+ print( 'File ' + gcodec.getSummarizedFilename( fileName ) + ' is being chain twitterbotted.' )
+ suffixFilename = fileName[ : fileName.rfind( '.' ) ] + '_twitterbot.gcode'
+ twitterbotGcode = getTwitterbotChainGcode( fileName, '', twitterbotPreferences )
+ if twitterbotGcode == '':
+ return
+ gcodec.writeFileText( suffixFilename, twitterbotGcode )
+ print( 'The twitterbotted file is saved as ' + gcodec.getSummarizedFilename( suffixFilename ) )
+ analyze.writeOutput( suffixFilename, twitterbotGcode )
+ print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to add Twitterbot codes to the file.' )
+
+ class TwitterbotPreferences:
+ "A class to handle the twitterbot preferences."
+ def __init__( self ):
+ "Set the default preferences, execute title & preferences fileName."
+ self.archive = []
+ self.activateTwitterbot = preferences.BooleanPreference().getFromValue( 'Activate Twitterbot', False )
+ self.archive.append( self.activateTwitterbot )
+ self.twitterUsername = preferences.StringPreference().getFromValue( 'Twitter Username:', '' )
+ self.archive.append( self.twitterUsername )
+ self.twitterPassword = preferences.StringPreference().getFromValue( 'Twitter Password:', '' )
+ self.archive.append( self.twitterPassword )
+ self.layersBetweenTweets = preferences.StringPreference().getFromValue( 'Layers Between Tweets:', '10' )
+ self.archive.append( self.layersBetweenTweets )
+ self.twitterHashtags = preferences.StringPreference().getFromValue( 'Hashtag(s):', '#MakerBot #Twitterbot' )
+ self.archive.append( self.twitterHashtags )
+ self.fileNameInput = preferences.Filename().getFromFilename( interpret.getGNUTranslatorGcodeFileTypeTuples(), 'Open File to insert Twitterbot code into', '' )
+ self.archive.append( self.fileNameInput )
+ #Create the archive, title of the execute button, title of the dialog & preferences fileName.
+ self.executeTitle = 'Twitterbot'
+ self.saveTitle = 'Save Preferences'
+ preferences.setHelpPreferencesFileNameTitleWindowPosition( self, 'skeinforge_tools.twitterbot.html' )
+
+ def execute( self ):
+ "Twitterbot button has been clicked."
+ fileNames = polyfile.getFileOrDirectoryTypesUnmodifiedGcode( self.fileNameInput.value, interpret.getImportPluginFilenames(), self.fileNameInput.wasCancelled )
+ for fileName in fileNames:
+ writeOutput( fileName )
+
+ class TwitterbotSkein:
+ "A class to insert Twitter M-code into a gcode file."
+ def __init__( self ):
+ self.lineIndex = 0
+ self.lines = None
+ self.output = cStringIO.StringIO()
+ # Twitterbot
+ self.gcodeFilePathAndName = ''
+ self.gcodeFileName = ''
+ self.gcodeFilePath = ''
+ self.savedGcodeFilename = ''
+ self.layerIndex = 1
+ self.twitterbotClass = 'TwitterBot'
+ self.mCodeInit = 'M997'
+ self.mCodeMessage = 'M998'
+ # Not used yet
+ self.mCodeCleanup = 'M999'
+
+ def setGcodeFilePathAndName( self, gcodeFilePathAndName ):
+ "Save path and filename of gcode file to this class. Called by getTwitterbotGcode()"
+ self.gcodeFilePathAndName = gcodeFilePathAndName
+
+ def addLine( self, line ):
+ "Add a line of text and a newline to the output."
+ self.output.write( line + "\n" )
+
+ def parseGcode( self, gcodeText, twitterbotPreferences ):
+ "Parse gcode text and store the twitterbot gcode."
+ self.lines = gcodec.getTextLines( gcodeText )
+ self.twitterUsername = twitterbotPreferences.twitterUsername.value
+ self.twitterPassword = twitterbotPreferences.twitterPassword.value
+ self.layersBetweenTweets = twitterbotPreferences.layersBetweenTweets.value
+ if int( self.layersBetweenTweets ) < 1:
+ self.layersBetweenTweets = '5'
+ self.twitterHashtags = twitterbotPreferences.twitterHashtags.value
+ #self.fileName = twitterbotPreferences.fileNameInput.value
+ self.parseInitialization( twitterbotPreferences )
+ #print( "===> self.lineIndex: " + str( self.lineIndex ) )
+ for self.lineIndex in xrange( self.lineIndex, len( self.lines ) ):
+ line = self.lines[ self.lineIndex ]
+ # print( '===> Parsing line ' + str( self.lineIndex ) + ': ' + line )
+ self.parseLine( line )
+
+ def parseInitialization( self, twitterbotPreferences ):
+ "Parse gcode initialization and store the parameters."
+ for self.lineIndex in xrange( len( self.lines ) ):
+ line = self.lines[ self.lineIndex ]
+ splitLine = line.split()
+ firstWord = gcodec.getFirstWord( splitLine )
+ if firstWord == '(<extruderInitialization>)':
+ self.addLine( '(Twitterbot initialization)' )
+ self.addLine( self.mCodeInit + ' ' + self.twitterbotClass + ' ' + self.twitterUsername + ',' + self.twitterPassword )
+ self.getSavedGCodeFileName()
+ print( 'self.savedGcodeFilename: ' + self.savedGcodeFilename )
+ self.addLine( self.createMessage( 'Starting ' + self.savedGcodeFilename + '...' ) )
+ elif firstWord == '(</extruderInitialization>)':
+ self.addLine( '(<procedureDone> twitterbot </procedureDone>)' )
+ return
+ self.addLine( line )
+
+ def parseLine( self, line ):
+ "Parse a gcode line and add Twitter M-code to it."
+ splitLine = line.split()
+ if len( splitLine ) < 1:
+ return
+ firstWord = splitLine[ 0 ]
+ #print( "===> firstWord: " + firstWord )
+ if firstWord == '(<layer>':
+ if self.layerIndex == 1:
+ self.addLine( self.createMessage( self.savedGcodeFilename + ': layer ' + str( self.layerIndex ) ) )
+ if self.layerIndex % int( self.layersBetweenTweets ) == 0:
+ self.addLine( self.createMessage( self.savedGcodeFilename + ': layer ' + str( self.layerIndex ) ) )
+ self.layerIndex = self.layerIndex + 1
+ elif firstWord == '(</extrusion>)':
+ self.getSavedGCodeFileName()
+ self.addLine( self.createMessage( 'Finished ' + self.savedGcodeFilename + '!' ) )
+ self.addLine( line )
+
+ def getSavedGCodeFileName( self ):
+ "Get original filename and change to the skeinforged one, i.e., ???_export.gcode."
+ if self.savedGcodeFilename == '':
+ self.gcodeFilePath,self.gcodeFileName = os.path.split( self.gcodeFilePathAndName )
+ self.savedGcodeFilename = self.gcodeFileName[ : self.gcodeFileName.rfind( '.' ) ] + '_export.gcode'
+
+ def createMessage( self, messageText ):
+ "Add the message M-Code to a string and return it."
+ msg = self.mCodeMessage + " message '" + messageText + " " + self.twitterHashtags + "'"
+ #print( '===> msg: ' + msg )
+ return msg
+
+ def main( hashtable = None ):
+ "Display the Twitterbot dialog."
+ if len( sys.argv ) > 1:
+ writeOutput( ' '.join( sys.argv[ 1 : ] ) )
+ else:
+ preferences.displayDialog( TwitterbotPreferences() )
+
+ if __name__ == "__main__":
+ main()
\ No newline at end of file