Skip to content

Commit 60ea095

Browse files
implemented exceptions in place of logging error messages to indicate important events
1 parent 8633931 commit 60ea095

File tree

8 files changed

+460
-466
lines changed

8 files changed

+460
-466
lines changed

docs/rot2prog/rot2prog.html

Lines changed: 286 additions & 302 deletions
Large diffs are not rendered by default.

docs/rot2prog/utils/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h2 class="section-title" id="header-submodules">Sub-modules</h2>
3636
<dl>
3737
<dt><code class="name"><a title="rot2prog.utils.run" href="run.html">rot2prog.utils.run</a></code></dt>
3838
<dd>
39-
<div class="desc"></div>
39+
<div class="desc"><p>Standalone program to manually interact with the ROT2Prog hardware.</p></div>
4040
</dd>
4141
<dt><code class="name"><a title="rot2prog.utils.sim" href="sim.html">rot2prog.utils.sim</a></code></dt>
4242
<dd>

docs/rot2prog/utils/run.html

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
66
<meta name="generator" content="pdoc 0.10.0" />
77
<title>rot2prog.utils.run API documentation</title>
8-
<meta name="description" content="" />
8+
<meta name="description" content="Standalone program to manually interact with the ROT2Prog hardware." />
99
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
1010
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
1111
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
@@ -22,42 +22,36 @@
2222
<h1 class="title">Module <code>rot2prog.utils.run</code></h1>
2323
</header>
2424
<section id="section-intro">
25+
<p>Standalone program to manually interact with the ROT2Prog hardware.</p>
2526
<details class="source">
2627
<summary>
2728
<span>Expand source code</span>
2829
</summary>
29-
<pre><code class="python">import logging
30+
<pre><code class="python">&#34;&#34;&#34;Standalone program to manually interact with the ROT2Prog hardware.
31+
&#34;&#34;&#34;
32+
import logging
3033
import rot2prog
3134

3235
def help():
36+
&#34;&#34;&#34;Displays a help message.
37+
&#34;&#34;&#34;
3338
print()
3439
print(&#39;ROT2Prog Live Interface Commands.&#39;)
3540
print()
3641
print(&#39;options:&#39;)
3742
print(&#39; help display this help message&#39;)
3843
print(&#39; quit end the program&#39;)
39-
print(&#39; ppd show pulses per degree&#39;)
4044
print(&#39; stop send stop command&#39;)
4145
print(&#39; status send status command&#39;)
46+
print(&#39; ppd show pulses per degree&#39;)
4247
print(&#39; set [azimuth] [elevation] send set command with a position&#39;)
4348

4449
if __name__ == &#39;__main__&#39;:
45-
log = logging.getLogger(__name__)
46-
47-
debug = &#39;&#39;
48-
49-
while debug.lower() not in [&#39;y&#39;, &#39;n&#39;]:
50-
debug = input(&#39;Run debugger? (y/n) &#39;)
51-
52-
if debug.lower() == &#39;y&#39;:
53-
logging.basicConfig(level = logging.DEBUG)
54-
print(&#39;Running in debug mode&#39;)
55-
else:
56-
logging.basicConfig(level = logging.INFO)
50+
logging.basicConfig(level = logging.DEBUG)
5751

5852
port = input(&#39;Please enter the serial port: &#39;)
59-
6053
rot = rot2prog.ROT2Prog(port)
54+
6155
help()
6256

6357
run = True
@@ -67,26 +61,26 @@ <h1 class="title">Module <code>rot2prog.utils.run</code></h1>
6761
args = cmd.split(&#39; &#39;)
6862

6963
try:
70-
if args[0].lower() == &#39;stop&#39;:
64+
if args[0].lower() == &#39;help&#39;:
65+
help()
66+
elif args[0].lower() == &#39;quit&#39;:
67+
run = False
68+
elif args[0].lower() == &#39;stop&#39;:
7169
rsp = rot.stop()
72-
log.info(&#39;Azimuth: &#39; + str(rsp[0]))
73-
log.info(&#39;Elevation: &#39; + str(rsp[1]))
70+
print(&#39;Azimuth: &#39; + str(rsp[0]))
71+
print(&#39;Elevation: &#39; + str(rsp[1]))
7472
elif args[0].lower() == &#39;status&#39;:
7573
rsp = rot.status()
76-
log.info(&#39;Azimuth: &#39; + str(rsp[0]))
77-
log.info(&#39;Elevation: &#39; + str(rsp[1]))
74+
print(&#39;Azimuth: &#39; + str(rsp[0]))
75+
print(&#39;Elevation: &#39; + str(rsp[1]))
76+
elif args[0].lower() == &#39;ppd&#39;:
77+
print(&#39;Pulses Per Degree: &#39; + str(rot.get_pulses_per_degree()))
7878
elif args[0].lower() == &#39;set&#39;:
7979
rot.set(float(args[1]), float(args[2]))
80-
elif args[0].lower() == &#39;ppd&#39;:
81-
log.info(&#39;Pulses Per Degree: &#39; + str(rot.get_pulses_per_degree()))
82-
elif args[0].lower() == &#39;help&#39;:
83-
help()
84-
elif args[0].lower() == &#39;quit&#39;:
85-
run = False
8680
else:
87-
raise Exception
88-
except:
89-
log.error(&#39;Invalid command!&#39;)
81+
raise Exception(&#39;Invalid command!&#39;)
82+
except Exception as e:
83+
print(e)
9084
help()</code></pre>
9185
</details>
9286
</section>
@@ -101,21 +95,23 @@ <h2 class="section-title" id="header-functions">Functions</h2>
10195
<span>def <span class="ident">help</span></span>(<span>)</span>
10296
</code></dt>
10397
<dd>
104-
<div class="desc"></div>
98+
<div class="desc"><p>Displays a help message.</p></div>
10599
<details class="source">
106100
<summary>
107101
<span>Expand source code</span>
108102
</summary>
109103
<pre><code class="python">def help():
104+
&#34;&#34;&#34;Displays a help message.
105+
&#34;&#34;&#34;
110106
print()
111107
print(&#39;ROT2Prog Live Interface Commands.&#39;)
112108
print()
113109
print(&#39;options:&#39;)
114110
print(&#39; help display this help message&#39;)
115111
print(&#39; quit end the program&#39;)
116-
print(&#39; ppd show pulses per degree&#39;)
117112
print(&#39; stop send stop command&#39;)
118113
print(&#39; status send status command&#39;)
114+
print(&#39; ppd show pulses per degree&#39;)
119115
print(&#39; set [azimuth] [elevation] send set command with a position&#39;)</code></pre>
120116
</details>
121117
</dd>

docs/rot2prog/utils/sim.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ <h1 class="title">Module <code>rot2prog.utils.sim</code></h1>
4646
logging.basicConfig(level = logging.INFO)
4747

4848
while resolution not in [1, 2, 4]:
49-
resolution = int(input(&#39;Pulses per degree: &#39;))
49+
resolution = input(&#39;Pulses per degree: &#39;)
50+
try:
51+
resolution = int(resolution)
52+
except ValueError:
53+
pass
5054

5155
port = input(&#39;Please enter the serial port: &#39;)
52-
5356
sim = rot2prog.ROT2ProgSim(port, resolution)
5457

5558
logging.getLogger().info(&#39;Press [Enter] to close simulator&#39;)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setuptools.setup(
1111
name = "rot2prog",
12-
version = "0.0.6",
12+
version = "0.0.7",
1313
author = "TJ Scherer",
1414
author_email = "[email protected]",
1515
description = "A python interface to the Alfa ROT2Prog Controller.",

0 commit comments

Comments
 (0)