Dear all,
Would you please show me how I can build the final Astrobox SD image (like those from https://www.astroprint.com/downloads) from source code (https://github.com/AstroPrint/AstroBox)? I’d like to try this by myself rather than only get the image from the download page. Thank you a lot.
Compiling images from source is HIGHLY NOT RECOMMENDED and a major pain in the ass.
The likelihood that something will go wrong is very high.
With that said, only @daniel could give you a definite answer on the exact process
May I ask: why do you want to do this anyway? Are you trying to get it working on custom hardware?
@dilanka:
Thank you for your quick response for such a nightmare:-)
Actually I am expecting to do some debug or learning on Astrbox + Raspberry.
Till now I’ve built a Astrobox by myself, and also read some source code of https://github.com/AstroPrint/AstroBox. And I am trying to change the source code, such as .js and .py files. But don’t know how to check the effect.
So if there are some guide on the exact build/release process from source code to image, it would be a benefit for me.
I have been looking into this as well, hoping to get it working on a BBP fastbot board.
@dilanka,
Seems that Daniel is absent right now:-) And would you please help me on such below small question?
In the source code, there are many .js files, such as AstroBox\src\astroprint\static\js\app\views\control.js, but in the final image on Raspberry board, there is no such file.
And I know actually it is combined into the app.js in image with many other .js files.
So my question is how I can verify my own changes in control.js in source code? I mean how can I get such changes into the final images.
Thank you a lot.
Other than known customizations – I have done zero exploring of the Astrobox source code, nor do I have any interest in doing so anytime soon
You are on your own on this one my friend – if you do discover a solution, feel free to post it here though!
@dilanka
Ok, I will be on my own way, and keep trying.
@daniel,
Any suggestion for us? Thank you a lot.
We haven’t yet focused on making the source easy to build as-is (something we need to do but haven’t had time).
Try editing or creating application.cfg
file in the same directory as your config.yaml
. The contents of that file should be:
ASSETS_DEBUG = True
ASSETS_AUTO_BUILD = True
@Daniel,
Thanks. But I don’t quietly understand some part of your reply. Sorry for I am totally newbie here. Actually I have two questions here.
The 1st one is the source build step. I know this could not be easy. So let’s ignore this one now. Maybe someday you could give us more about this:-)
The 2nd one could possibly be easier. Let me explain more. As seen in the source code, we have these two folders, And in both, there is a gen\ folder with empty file there.
src\astroprint\static\css\gen
src\astroprint\static\js\gen
When we come to the Raspberry board, there are also two relevant folders, and I found many .js files in source code are combined/merged into fewer ones in image.
/AstroBox/src/astroprint/static/js/gen
/AstroBox/src/astroprint/static/css/gen
So my question is how these happens, and how I can merge/combine my change in source code level into the final image?
Thank you very much in advance.
@Daniel,
I can hack the final .js(eg, /AstroBox/src/astroprint/static/js/gen/app.js) in image directly to verify some change, but actually it is almost unreadable.
And I know this is absolutely NOT the normal way for development.
So could you pls help me on this newbie problem? How to combine/merge those changes of readable .js files in source code into the final unreadable .js in the final image? Any build script/tool to do such thing?
If you change the application.cfg
file that I mentioned before, the software will use the individual .js files instead of the generated and combined .js one.
Do you mean the following steps?
-
Change the /etc/astrobox/application.cfg in image into
ASSETS_DEBUG = True
ASSETS_AUTO_BUILD = True -
For /AstroBox/src/astroprint/static/js/ and /AstroBox/src/astroprint/static/css/ folders in image, directly use the corresponding source code folders to replace them.
-
reboot my raspberry board
No, you need to clone the AstroBox repo on your raspberry pi first.
After you’ve cloned the system, you should stop the current one with:
sudo service astrobox stop
and start the new one using the repo you cloned. From the astrobox cloned directory:
python ./run --config /etc/astrobox/config.yaml
OK, let me try. Thank you a lot, and I will come back with the result soon:-)
@Daniel,
I tried your steps, but I failed with below errors, and seems fail to start the astrobox service. Any suggestion for me to move on?
pi@astrobox-5026 ~/AstroBox $ sudo python -OO ./run --config /etc/astrobox/config.yaml
2016-02-28 19:54:45,658 - octoprint.server - INFO - Starting AstroBox (AstroBox - v0.8(5))
2016-02-28 19:54:45,775 - astroprint.printfiles.gcode - INFO - Migrating metadata if necessary…
2016-02-28 19:54:45,776 - astroprint.printfiles.gcode - INFO - Updated 0 sets of metadata to new format
2016-02-28 19:54:46,422 - astroprint.boxrouter - INFO - This box has id 81a6145f4db04f06a7fe3b6a1cf8455e
2016-02-28 19:54:46,544 - astroprint.network.debian - INFO - NetworkManagerEvents is listening for signals
2016-02-28 19:54:49,886 - astroprint.network.debian - INFO - Looking for Active Connections…
2016-02-28 19:54:49,954 - octoprint.server - INFO - Listening on http://127.0.0.1:5000
2016-02-28 19:54:50,038 - astroprint.network.debian - INFO - Active Connection is now eth0 (192.168.199.202)
2016-02-28 19:54:50,041 - astroprint.boxrouter - INFO - Device is online. Attempting to connect to box router.
2016-02-28 19:54:53,091 - astroprint.discovery - INFO - Registered astrobox-5026 for SSDP
2016-02-28 19:54:53,636 - astroprint.boxrouter - INFO - Connected to astroprint service
2016-02-28 19:56:03,014 - octoprint - ERROR - Exception on / [GET]
Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 1817, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 1475, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File “/home/pi/AstroBox/src/octoprint/server/init.py”, line 151, in index
serialLogActive= s.getBoolean([‘serial’, ‘log’])
File “/usr/local/lib/python2.7/dist-packages/flask/templating.py”, line 128, in render_template
context, ctx.app)
File “/usr/local/lib/python2.7/dist-packages/flask/templating.py”, line 110, in _render
rv = template.render(context)
File “/usr/local/lib/python2.7/dist-packages/jinja2/environment.py”, line 969, in render
return self.environment.handle_exception(exc_info, True)
File “/usr/local/lib/python2.7/dist-packages/jinja2/environment.py”, line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File “/home/pi/AstroBox/src/octoprint/…/astroprint/templates/app.jinja2”, line 1, in top-level template code
{% extends ‘base.jinja2’ %}
File “/home/pi/AstroBox/src/octoprint/…/astroprint/templates/base.jinja2”, line 9, in top-level template code
{% block css %}{% endblock %}
File “/home/pi/AstroBox/src/octoprint/…/astroprint/templates/app.jinja2”, line 9, in block “css”
{% assets filters=“scss”, output=“css/gen/app.css”, “css/scss/app.scss” %}
File “/usr/local/lib/python2.7/dist-packages/webassets/ext/jinja2.py”, line 186, in _render_assets
urls = bundle.urls()
File “/usr/local/lib/python2.7/dist-packages/webassets/bundle.py”, line 787, in urls
urls.extend(bundle._urls(new_ctx, extra_filters, *args, **kwargs))
File “/usr/local/lib/python2.7/dist-packages/webassets/bundle.py”, line 746, in _urls
*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/webassets/bundle.py”, line 600, in _build
force, disable_cache=disable_cache, extra_filters=extra_filters)
File “/usr/local/lib/python2.7/dist-packages/webassets/bundle.py”, line 524, in _merge_and_apply
kwargs=item_data)
File “/usr/local/lib/python2.7/dist-packages/webassets/merge.py”, line 277, in apply
return self._wrap_cache(key, func)
File “/usr/local/lib/python2.7/dist-packages/webassets/merge.py”, line 219, in _wrap_cache
content = func().getvalue()
File “/usr/local/lib/python2.7/dist-packages/webassets/merge.py”, line 252, in func
getattr(filter, type)(data, out, **kwargs_final)
File “/usr/local/lib/python2.7/dist-packages/webassets/filter/sass.py”, line 146, in input
self._apply_sass(_in, out, os.path.dirname(source_path))
File “/usr/local/lib/python2.7/dist-packages/webassets/filter/sass.py”, line 127, in _apply_sass
shell=(os.name == ‘nt’))
File “/usr/lib/python2.7/subprocess.py”, line 679, in init
errread, errwrite)
File “/usr/lib/python2.7/subprocess.py”, line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
@Daniel,
The above error of “OSError: [Errno 2] No such file or directory” is due to sass missing.
After I apt-get install ruby and apt-get install ruby-sass, the astrobox service can be started, and I can access the Astrobox’s web page from browser. Thank you a lot.
And I will continue to change those source code files, eg, .js files to see the result.
@Daniel,
Thank you a lot. Finally I can change the source code on raspberry board directly now.
On the other hand of our discussion, could you please show us how to generate the combined/compressed .js files and the .css files just like those in the downloaded image? I mean /AstroBox/src/astroprint/static/js/gen and /AstroBox/src/astroprint/static/css/gen.
We’re not planning on releasing our packaging tools at the moment but you don’t really need them to develop on the astrobox.
Please do create a pull request is what you’re doing should be consider part of the official release.
Ok, got it. Thank you again on the way.
Hey there, I followed all the steps mentioned above but still I am unable to run Astrobox from the source code. I am getting the following errors:
2017-05-31 07:49:22,423 - octoprint - ERROR - Exception on / [GET]
Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 1817, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 1475, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python2.7/dist-packages/flask/app.py”, line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File “/home/pi/AstroBox/src/octoprint/server/init.py”, line 162, in index
wsToken= create_ws_token(userManager.findUser(loggedUsername).publicKey if loggedUsername else None)
File “/usr/local/lib/python2.7/dist-packages/flask/templating.py”, line 128, in render_template
context, ctx.app)
File “/usr/local/lib/python2.7/dist-packages/flask/templating.py”, line 110, in _render
rv = template.render(context)
File “/usr/local/lib/python2.7/dist-packages/jinja2/environment.py”, line 989, in render
return self.environment.handle_exception(exc_info, True)
File “/usr/local/lib/python2.7/dist-packages/jinja2/environment.py”, line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File “/home/pi/AstroBox/src/octoprint/…/astroprint/templates/app.jinja2”, line 1, in top-level template code
{% extends ‘base.jinja2’ %}
File “/home/pi/AstroBox/src/octoprint/…/astroprint/templates/base.jinja2”, line 9, in top-level template code
{% block css %}{% endblock %}
File “/home/pi/AstroBox/src/octoprint/…/astroprint/templates/app.jinja2”, line 5, in block “css”
{% assets filters=“scss”, output=“css/gen/login.css”, “css/scss/login.scss” %}
File “/usr/local/lib/python2.7/dist-packages/webassets/ext/jinja2.py”, line 186, in _render_assets
urls = bundle.urls()
File “/usr/local/lib/python2.7/dist-packages/webassets/bundle.py”, line 787, in urls
urls.extend(bundle._urls(new_ctx, extra_filters, *args, **kwargs))
File “/usr/local/lib/python2.7/dist-packages/webassets/bundle.py”, line 746, in _urls
*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/webassets/bundle.py”, line 600, in _build
force, disable_cache=disable_cache, extra_filters=extra_filters)
File “/usr/local/lib/python2.7/dist-packages/webassets/bundle.py”, line 524, in _merge_and_apply
kwargs=item_data)
File “/usr/local/lib/python2.7/dist-packages/webassets/merge.py”, line 276, in apply
return self._wrap_cache(key, func)
File “/usr/local/lib/python2.7/dist-packages/webassets/merge.py”, line 218, in _wrap_cache
content = func().getvalue()
File “/usr/local/lib/python2.7/dist-packages/webassets/merge.py”, line 251, in func
getattr(filter, type)(data, out, **kwargs_final)
File “/usr/local/lib/python2.7/dist-packages/webassets/filter/sass.py”, line 196, in input
self._apply_sass(_in, out, os.path.dirname(source_path))
File “/usr/local/lib/python2.7/dist-packages/webassets/filter/sass.py”, line 190, in _apply_sass
return self.subprocess(args, out, _in)
File “/usr/local/lib/python2.7/dist-packages/webassets/filter/init.py”, line 523, in subprocess
proc.returncode, stdout, stderr))
FilterError: scss: subprocess returned a non-success result code: 65, stdout=, stderr=Error: File to import not found or unreadable: foundation/components/global.
Load path: /home/pi/AstroBox (DEPRECATED)
on line 5 of standard input
Use --trace for backtrace.
Help me figure this out, I have even installed sass and ruby as @dingcatdang mentioned still no luck.