Skip to content

Debugging with docker

skymandr edited this page Jun 7, 2017 · 1 revision

For security reasons debugging in Scan-o-matic is restricted to running with the --local option set, which makes debugging in a dockerized environment a little cumbersome. This is scheduled to be fixed in the near future, but for now (2016-06-07), this workaround can help.

First implement the following changes (they should, under no circumstances, be checked in to the master branch, and should not be used in a production environment):

diff --git a/scanomatic/io/logger.py b/scanomatic/io/logger.py
index a5b3d5b..d8dd188 100644
--- a/scanomatic/io/logger.py
+++ b/scanomatic/io/logger.py
@@ -265,7 +265,7 @@ class Logger(object):
     @surpress_prints.setter
     def surpress_prints(self, value):
 
-        self._suppressPrints = value
+        self._suppressPrints = False
 
     def _decorate(self, lvl):
 
@@ -290,7 +290,7 @@ class Logger(object):
 
                 output.writelines(msg)
 
-            elif not self._suppressPrints:
+            if not self._suppressPrints:
 
                 print(self._decorate(lvl) + str(msg))
 
diff --git a/scanomatic/ui_server/calibration_api.py b/scanomatic/ui_server/calibration_api.py
index 5268492..457e5d3 100644
--- a/scanomatic/ui_server/calibration_api.py
+++ b/scanomatic/ui_server/calibration_api.py
@@ -201,6 +201,7 @@ def add_routes(app):
         if data is None:
             return jsonify(success=False, is_endpoint=True,
                            reason="The image or CCC don't exist or not enough info set to do slice")
+        print data['plates']
 
         success = calibration.save_image_slices(
             ccc_identifier, image_identifier,
diff --git a/scanomatic/ui_server/general.py b/scanomatic/ui_server/general.py
index 3b9b3fd..636b121 100644
--- a/scanomatic/ui_server/general.py
+++ b/scanomatic/ui_server/general.py
@@ -515,7 +515,7 @@ def decorate_access_restriction(restricted_route):
         def __getattribute__(self, item):
 
             def restrictor(*args, **kwargs):
-                if not _app_runs_locally or is_local_ip(request.remote_addr):
+                if True:
                     return restricted_route(*args, **kwargs)
                 else:
                     _logger.warning("Illegal access attempt to {0} from {1}".format(restricted_route, request.remote_addr))
diff --git a/scanomatic/ui_server/ui_server.py b/scanomatic/ui_server/ui_server.py
index fd10133..9971740 100644
--- a/scanomatic/ui_server/ui_server.py
+++ b/scanomatic/ui_server/ui_server.py
@@ -559,8 +559,7 @@ def launch_server(is_local=None, port=None, host=None, debug=False):
         else:
             if debug:
                 _logger.warning("Debugging is only allowed on local servers")
-            else:
-                app.run(port=port, host=host)
+            app.run(port=port, host=host, debug=debug)
 
     except error:
 _logger.warning("Could not bind socket, probably server is already running and this is nothing to worry about."

Scan-o-matic can then be started in dockerized-debug mode, for instance by using this docker-compose file:

scanomatic-debug:
  build: .
  ports:
    - 5000:5000
    - 12451:12451
  entrypoint: scan-o-matic --no-browser --global --debug

Clone this wiki locally