chiark / gitweb /
Step up major version number for release
[cura.git] / Cura / cura.py
index 36e487b224fa8b0ffa13afe2269a1a2fa386f064..c6d4e80b0d2cda886f8eb93fd7f7c1a3f35c8bb1 100644 (file)
@@ -13,11 +13,12 @@ from optparse import OptionParser
 from Cura.util import profile
 
 def main():
+       """
+       Main Cura entry point. Parses arguments, and starts GUI or slicing process depending on the arguments.
+       """
        parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
        parser.add_option("-i", "--ini", action="store", type="string", dest="profileini",
                help="Load settings from a profile ini file")
-       parser.add_option("-r", "--print", action="store", type="string", dest="printfile",
-               help="Open the printing interface, instead of the normal cura interface.")
        parser.add_option("-p", "--profile", action="store", type="string", dest="profile",
                help="Internal option, do not use!")
        parser.add_option("-s", "--slice", action="store_true", dest="slice",
@@ -31,7 +32,8 @@ def main():
 
        if options.serialCommunication:
                from Cura import serialCommunication
-               serialCommunication.startMonitor(options.serialCommunication)
+               port, baud = options.serialCommunication.split(':')
+               serialCommunication.startMonitor(port, baud)
                return
 
        print "load preferences from " + profile.getPreferencePath()
@@ -42,12 +44,9 @@ def main():
        elif options.profileini is not None:
                profile.loadProfile(options.profileini)
        else:
-               profile.loadProfile(profile.getDefaultProfilePath())
+               profile.loadProfile(profile.getDefaultProfilePath(), True)
 
-       if options.printfile is not None:
-               from Cura.gui import printWindow
-               printWindow.startPrintInterface(options.printfile)
-       elif options.slice is not None:
+       if options.slice is not None:
                from Cura.util import sliceEngine
                from Cura.util import objectScene
                from Cura.util import meshLoader
@@ -66,9 +65,14 @@ def main():
                engine.wait()
 
                if not options.output:
-                       options.output = args[0] + '.gcode'
+                       options.output = args[0] + profile.getGCodeExtension()
                with open(options.output, "wb") as f:
-                       f.write(engine.getResult().getGCode())
+                       gcode = engine.getResult().getGCode()
+                       while True:
+                               data = gcode.read()
+                               if len(data) == 0:
+                                       break
+                               f.write(data)
                print 'GCode file saved : %s' % options.output
 
                engine.cleanup()
@@ -77,4 +81,15 @@ def main():
                app.CuraApp(args).MainLoop()
 
 if __name__ == '__main__':
+       import os
+       import sys
+
+       # On Windows, the PATH variable can cause the search path for dlls
+       # to give priority to dlls from other applications and it will cause
+       # the bundled python dlls not to be loaded.
+       # More specifically, anyone with Haskell Platform installed will not
+       # be able to launch Cura because glut32.dll from Haskell is incompatible
+       # with the bundled py-opengl and will cause Cura to crash
+       if sys.platform.startswith('win'):
+               os.environ['PATH'] = ''
        main()