Commit 60cf6c3
authored
Check a valid service name has been provided (#171)
- Remove some redundant parameters.
- Construct the known_services help string separately (we'll use it
again).
- Exit early if no service has been specified, instead of opening a
frontend with no service and quietly twiddling our thumbs.
No attempt is made here to migrate to argparse.ArgumentParser instead of
the deprecated optparse.OptionParser, though the 'required' argument of
'ArgumentParser.add_argument' would obviate the need for separately
checking whether the '--service' option has been invoked.
* Tidy up the service name resolution logic
At present, a user can grow accustomed to lazily providing lower-case
service names when invoking 'workflows.service' from the command line.
This works fine until you encounter the following situation:
- Known services include "DLSISPyB" and "DLSISPyBPIA";
- user specifies '-s dlsispyb', expecting this to be interpreted as
'DLSISPyB', or else expecting an error;
- not finding a perfect match, the current logic checks whether any
known service names, rendered in lower case, start with 'dlsispyb',
finds two such matches;
- rather than selecting either of these two matches, the program quietly
continues to open a frontend and doesn't start any service;
- user sees so warning or error, program twiddles its thumbs until
terminated.
New logic:
1. Check for perfect match;
2. Failing that, check for case-insensitive match;
3. Failing that, check for case-sensitive partial matches. If
ambiguous, exit with error.
4. Failing that, repeat 3 but now case-insensitive.
5. If still no matches, exit with error.
* Neaten up the if nots1 parent b20f7da commit 60cf6c3
1 file changed
+38
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
79 | | - | |
80 | 82 | | |
81 | | - | |
82 | | - | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | 87 | | |
89 | 88 | | |
90 | 89 | | |
| |||
95 | 94 | | |
96 | 95 | | |
97 | 96 | | |
98 | | - | |
99 | 97 | | |
100 | 98 | | |
101 | 99 | | |
102 | 100 | | |
103 | 101 | | |
104 | 102 | | |
105 | | - | |
106 | 103 | | |
107 | 104 | | |
108 | 105 | | |
| |||
111 | 108 | | |
112 | 109 | | |
113 | 110 | | |
114 | | - | |
115 | 111 | | |
116 | 112 | | |
117 | 113 | | |
118 | | - | |
119 | | - | |
| 114 | + | |
| 115 | + | |
120 | 116 | | |
121 | 117 | | |
122 | 118 | | |
123 | 119 | | |
124 | | - | |
125 | 120 | | |
126 | 121 | | |
127 | 122 | | |
| |||
137 | 132 | | |
138 | 133 | | |
139 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
140 | 139 | | |
141 | 140 | | |
142 | 141 | | |
| |||
155 | 154 | | |
156 | 155 | | |
157 | 156 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
169 | 185 | | |
170 | 186 | | |
171 | 187 | | |
| |||
0 commit comments