-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7f54768
Showing
43 changed files
with
5,780 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ab81b1b815cedb7ca1fdb7811bd4966f | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 — 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"> | ||
<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> »</li> | ||
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> »</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">"""Simple XML-RPC Server to run on the datastore server.</span> | ||
|
||
<span class="sd">This daemon should be run on HiSPARC'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">"""</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">'/tmp/hash_datastore'</span> | ||
<span class="n">DATASTORE_CFG</span> <span class="o">=</span> <span class="s1">'/databases/frome/station_list.csv'</span> | ||
<span class="n">CFG_URL</span> <span class="o">=</span> <span class="s1">'https://data.hisparc.nl/config/datastore'</span> | ||
<span class="n">DATASTORE_XMLRPC_SERVER</span> <span class="o">=</span> <span class="p">(</span><span class="s1">'192.168.99.13'</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">'/tmp/uwsgi-reload.me'</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">"""Load datastore config and reload datastore, if necessary"""</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">'w'</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">'a'</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">'w'</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">'__main__'</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">'/RPC2'</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'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"> | ||
<div class="sphinxsidebarwrapper"> | ||
<p class="logo"><a href="../../index.html"> | ||
<img class="logo" src="../../_static/header.png" alt="Logo of HiSPARC-datastore"/> | ||
</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"> | ||
<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> »</li> | ||
<li class="nav-item nav-item-1"><a href="../index.html" >Module code</a> »</li> | ||
<li class="nav-item nav-item-this"><a href="">examples.datastore_config_server</a></li> | ||
</ul> | ||
</div> | ||
<div class="footer" role="contentinfo"> | ||
© Copyright 2017, David Fokkema, Arne de Laat, Tom Kooij. | ||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.0.2. | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 — 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"> | ||
<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> »</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"> | ||
<div class="sphinxsidebarwrapper"> | ||
<p class="logo"><a href="../index.html"> | ||
<img class="logo" src="../_static/header.png" alt="Logo of HiSPARC-datastore"/> | ||
</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"> | ||
<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> »</li> | ||
<li class="nav-item nav-item-this"><a href="">Overview: module code</a></li> | ||
</ul> | ||
</div> | ||
<div class="footer" role="contentinfo"> | ||
© Copyright 2017, David Fokkema, Arne de Laat, Tom Kooij. | ||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.0.2. | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.