Skip to content

Commit

Permalink
deploy: 4f57e8e
Browse files Browse the repository at this point in the history
  • Loading branch information
153957 committed Jun 26, 2024
0 parents commit 09cf817
Show file tree
Hide file tree
Showing 43 changed files with 5,774 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: b63a20aed247b84d9dd92dbbcf71bcee
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file added .doctrees/environment.pickle
Binary file not shown.
Binary file added .doctrees/index.doctree
Binary file not shown.
Binary file added .doctrees/introduction.doctree
Binary file not shown.
Binary file added .doctrees/writer.doctree
Binary file not shown.
Binary file added .doctrees/wsgi.doctree
Binary file not shown.
Binary file added .doctrees/xml-rpc-server.doctree
Binary file not shown.
Empty file added .nojekyll
Empty file.
154 changes: 154 additions & 0 deletions _modules/examples/datastore_config_server.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<!DOCTYPE html>

<html lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>examples.datastore_config_server &#8212; HiSPARC-datastore 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../_static/nature.css?v=0f882399" />
<link rel="stylesheet" type="text/css" href="../../_static/hisparc_style.css?v=71c9f363" />
<script src="../../_static/documentation_options.js?v=8d563738"></script>
<script src="../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="icon" href="../../_static/favicon.ico"/>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">HiSPARC-datastore 1.0.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">examples.datastore_config_server</a></li>
</ul>
</div>

<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">

<h1>Source code for examples.datastore_config_server</h1><div class="highlight"><pre>
<span></span><span class="ch">#!/usr/local/bin/python</span>
<span class="sd">&quot;&quot;&quot;Simple XML-RPC Server to run on the datastore server.</span>

<span class="sd">This daemon should be run on HiSPARC&#39;s datastore server. It will</span>
<span class="sd">handle the cluster layouts and station passwords. When an update is</span>
<span class="sd">necessary, it will reload the HTTP daemon.</span>

<span class="sd">The basis for this code was ripped from the python SimpleXMLRPCServer</span>
<span class="sd">library documentation and extended.</span>

<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">hashlib</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">urllib.error</span>
<span class="kn">import</span> <span class="nn">urllib.parse</span>
<span class="kn">import</span> <span class="nn">urllib.request</span>

<span class="kn">from</span> <span class="nn">xmlrpc.server</span> <span class="kn">import</span> <span class="n">SimpleXMLRPCRequestHandler</span><span class="p">,</span> <span class="n">SimpleXMLRPCServer</span>

<span class="n">HASH</span> <span class="o">=</span> <span class="s1">&#39;/tmp/hash_datastore&#39;</span>
<span class="n">DATASTORE_CFG</span> <span class="o">=</span> <span class="s1">&#39;/databases/frome/station_list.csv&#39;</span>
<span class="n">CFG_URL</span> <span class="o">=</span> <span class="s1">&#39;https://data.hisparc.nl/config/datastore&#39;</span>
<span class="n">DATASTORE_XMLRPC_SERVER</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;192.168.99.13&#39;</span><span class="p">,</span> <span class="mi">8001</span><span class="p">)</span>
<span class="n">RELOAD_PATH</span> <span class="o">=</span> <span class="s1">&#39;/tmp/uwsgi-reload.me&#39;</span>


<div class="viewcode-block" id="reload_datastore">
<a class="viewcode-back" href="../../xml-rpc-server.html#examples.datastore_config_server.reload_datastore">[docs]</a>
<span class="k">def</span> <span class="nf">reload_datastore</span><span class="p">():</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Load datastore config and reload datastore, if necessary&quot;&quot;&quot;</span>

<span class="n">datastore_cfg</span> <span class="o">=</span> <span class="n">urllib</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="n">CFG_URL</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="n">new_hash</span> <span class="o">=</span> <span class="n">hashlib</span><span class="o">.</span><span class="n">sha1</span><span class="p">(</span><span class="n">datastore_cfg</span><span class="p">)</span><span class="o">.</span><span class="n">hexdigest</span><span class="p">()</span>

<span class="k">try</span><span class="p">:</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">HASH</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span>
<span class="n">old_hash</span> <span class="o">=</span> <span class="n">file</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span>
<span class="n">old_hash</span> <span class="o">=</span> <span class="kc">None</span>

<span class="k">if</span> <span class="n">new_hash</span> <span class="o">==</span> <span class="n">old_hash</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">DATASTORE_CFG</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span>
<span class="n">file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">datastore_cfg</span><span class="p">)</span>

<span class="c1"># reload uWSGI</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">RELOAD_PATH</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">):</span>
<span class="n">os</span><span class="o">.</span><span class="n">utime</span><span class="p">(</span><span class="n">RELOAD_PATH</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>

<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">HASH</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">file</span><span class="p">:</span>
<span class="n">file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">new_hash</span><span class="p">)</span>

<span class="k">return</span> <span class="kc">True</span></div>



<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
<span class="c1"># Restrict to a particular path.</span>
<span class="k">class</span> <span class="nc">RequestHandler</span><span class="p">(</span><span class="n">SimpleXMLRPCRequestHandler</span><span class="p">):</span>
<span class="n">rpc_paths</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;/RPC2&#39;</span><span class="p">,)</span>

<span class="c1"># Create server</span>
<span class="n">server</span> <span class="o">=</span> <span class="n">SimpleXMLRPCServer</span><span class="p">(</span><span class="n">DATASTORE_XMLRPC_SERVER</span><span class="p">,</span> <span class="n">requestHandler</span><span class="o">=</span><span class="n">RequestHandler</span><span class="p">)</span>
<span class="n">server</span><span class="o">.</span><span class="n">register_introspection_functions</span><span class="p">()</span>

<span class="n">server</span><span class="o">.</span><span class="n">register_function</span><span class="p">(</span><span class="n">reload_datastore</span><span class="p">)</span>

<span class="c1"># Run the server&#39;s main loop</span>
<span class="n">server</span><span class="o">.</span><span class="n">serve_forever</span><span class="p">()</span>
</pre></div>

<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../../index.html">
<img class="logo" src="../../_static/header.png" alt="Logo"/>
</a></p>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html">HiSPARC-datastore 1.0.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">examples.datastore_config_server</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2017, David Fokkema, Arne de Laat, Tom Kooij.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.3.7.
</div>
</body>
</html>
86 changes: 86 additions & 0 deletions _modules/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!DOCTYPE html>

<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &#8212; HiSPARC-datastore 1.0.0 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../_static/nature.css?v=0f882399" />
<link rel="stylesheet" type="text/css" href="../_static/hisparc_style.css?v=71c9f363" />
<script src="../_static/documentation_options.js?v=8d563738"></script>
<script src="../_static/doctools.js?v=9a2dae69"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">HiSPARC-datastore 1.0.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Overview: module code</a></li>
</ul>
</div>

<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">

<h1>All modules for which code is available</h1>
<ul><li><a href="examples/datastore_config_server.html">examples.datastore_config_server</a></li>
<li><a href="writer/storage.html">writer.storage</a></li>
<li><a href="writer/store_events.html">writer.store_events</a></li>
<li><a href="writer/writer_app.html">writer.writer_app</a></li>
<li><a href="wsgi/wsgi_app.html">wsgi.wsgi_app</a></li>
</ul>

<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/header.png" alt="Logo"/>
</a></p>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">HiSPARC-datastore 1.0.0 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Overview: module code</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2017, David Fokkema, Arne de Laat, Tom Kooij.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.3.7.
</div>
</body>
</html>
Loading

0 comments on commit 09cf817

Please sign in to comment.