Using pyarmor to obfuscate multiple tornado apps

Try to obfuscate a project using pyarmor written in tornado with multiple apps.

For a single app with the following structure, it was quite easy to obfuscate using pyarmor

.
├── apps
│   ├── __init__.py
│   └── app.py   # show below
└── handler
    ├── __init__.py
    └── myhandler.py
# apps/app.py

import tornado.ioloop
import tornado.web
from handler import MainHandler

def make_app():
    return tornado.web.Application([
        (r"/", MainHandler),
    ])

app = make_app()
server = tornado.httpserver.HTTPServer(app)
server.bind(8888)  # port
server.start(1)
tornado.ioloop.IOLoop.instance().start()

Just using the following command, where apps/app.py is the entry point for the tornado app

cd /myproject
pyarmor obfuscate --src="." -r --output=/path/tp/obs_site apps/app.py

Then we get the output folder which is an obfuscated project ready to be distributed. The start-up script is as the same before: python apps/app.py to start the tornado server.


Unfortunately, things become more complicated when dealing with multiple apps. Due to legacy reasons, components such as handlers and routes are not well organized and separated in different folders, due to the complexity of the whole project, it is infeasible to change the whole project structure for now.

Any ideas on how to obfuscate a project with dozens of apps below(2 apps for example) with the following structure, thanks in advance!

.
├── apps
│   ├── __init__.py
│   ├── app.py
│   └── app2.py
├── handler
│   ├── __init__.py
│   ├── myhandler.py
│   └── myhandler2.py
├── start.sh
└── stop.sh

Here is the start.sh shell to start multiple apps

# start.sh
python apps/app.py &
python apps/app2.py &
Back to Top