csaxs_bec.bec_ipython_client.plugins.flomni.flomni_webpage_generator#
flomni/webpage_generator.py#
Background thread that reads tomo progress from the BEC global variable store and writes status.json (every cycle) + status.html (once at startup) to a staging directory. An optional HttpUploader sends those files to a web host after every cycle, running in a separate daemon thread so uploads never block the generator cycle. A built-in LocalHttpServer always serves the output directory locally (default port 8080) so the page can be accessed on the lab network without any extra setup.
Architecture#
- LocalHttpServer – built-in HTTP server; serves output_dir on port 8080.
Always started at _launch(); URL printed to console.
- HttpUploader – non-blocking HTTP uploader (fire-and-forget thread).
Tracks file mtimes; only uploads changed files. Sends a cleanup request to the server when the ptycho scan ID changes (removes old S*_*.png/jpg).
- WebpageGeneratorBase – all common logic: queue, progress, idle detection,
reconstruction queue, HTML, audio, phone numbers, outdated-page warning. Import this in subclasses.
- FlomniWebpageGenerator – flomni-specific: temperatures, sample name, settings,
flOMNI logo.
- make_webpage_generator() – factory; selects the right class by session name.
Lazy-imports LamNI / omny subclasses to avoid circular dependencies.
Integration (inside Flomni.__init__, after self._progress_proxy.reset()):#
- from csaxs_bec.bec_ipython_client.plugins.flomni.webpage_generator import (
FlomniWebpageGenerator,
) self._webpage_gen = FlomniWebpageGenerator(
bec_client=client, output_dir=”~/data/raw/webpage/”, upload_url=”http://omny.online/upload.php”, # optional local_port=8080, # optional, default 8080
) self._webpage_gen.start() # On start(), the console prints: # ➜ Status page: http://hostname:8080/status.html
Interactive helpers (optional, in the iPython session):#
flomni._webpage_gen.status() # print current status + local URL flomni._webpage_gen.verbosity = 2 # VERBOSE: one-line summary per cycle flomni._webpage_gen.verbosity = 3 # DEBUG: full JSON per cycle flomni._webpage_gen.stop() # release lock, stop local server flomni._webpage_gen.start() # restart after stop() flomni.webpage_gen.set_web_password(“pw”) # set web password for current e-account
Session authentication:#
- Two htpasswd files are used on the remote server:
users.htpasswd – static, managed manually with htpasswd -B session.htpasswd – managed by the generator; one entry for the current e-account
At _launch(), the generator queries session_query.php to find which account was previously active. If the account has changed the session.htpasswd is cleared immediately (old user loses access) and uploaded. The new user calls set_web_password() to set their own password and gain access.
Functions
Select the appropriate WebpageGenerator subclass based on the BEC session name (bec._ip.prompts.session_name) and return a ready-to-start instance. |
Classes
flOMNI-specific webpage generator. |
|
Uploads files from a local directory to a remote server via HTTP POST. |
|
Serves the generator's output directory over plain HTTP in a daemon thread. |
|
Common webpage generator. Subclass and override: |