explorationtools: added findCommander
Let’s you, duh, find a Commander’s last known system if they are on EDSM and have their flight logs public.
This commit is contained in:
parent
d5a7943604
commit
c255277e89
3 changed files with 40 additions and 3 deletions
17
README.md
17
README.md
|
@ -23,7 +23,7 @@ optional arguments:
|
|||
## explorationtools.py ##
|
||||
|
||||
```
|
||||
usage: explorationtools.py [-h] {bodycount,distancebetween} ...
|
||||
usage: explorationtools.py [-h] {bodycount,distancebetween,findCommander} ...
|
||||
|
||||
A collection of tools useful for exploration.
|
||||
|
||||
|
@ -31,7 +31,7 @@ optional arguments:
|
|||
-h, --help show this help message and exit
|
||||
|
||||
subcommands:
|
||||
{bodycount,distancebetween}
|
||||
{bodycount,distancebetween,findCommander}
|
||||
sub-command help
|
||||
bodycount Returns the number of bodies in a system. Will exit
|
||||
with code 1 on server error and code 2 if the system
|
||||
|
@ -39,6 +39,9 @@ subcommands:
|
|||
distancebetween Calculates the distance between two systems. Will exit
|
||||
with code 1 on server error and code 2 if (one of) the
|
||||
systems could not be found on EDSM.
|
||||
findCommander Attempts to find a CMDR’s last known position. Will
|
||||
exit with code 1 on server error and code 2 if the
|
||||
CMDR could not be found on EDSM.
|
||||
```
|
||||
|
||||
```
|
||||
|
@ -60,3 +63,13 @@ positional arguments:
|
|||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
```
|
||||
|
||||
```
|
||||
usage: explorationtools.py findCommander [-h] name
|
||||
|
||||
positional arguments:
|
||||
name
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
```
|
||||
|
|
|
@ -25,6 +25,19 @@ def distanceBetween(system1, system2):
|
|||
+ (coords1['z']-coords2['z'])**2 ),0)))
|
||||
sys.exit(0)
|
||||
|
||||
def findCommander(name):
|
||||
try:
|
||||
currentSystem = Commander(name).currentSystem
|
||||
except ServerError as e:
|
||||
print(e)
|
||||
sys.exit(1)
|
||||
except NotFoundError as e:
|
||||
print(e)
|
||||
sys.exit(2)
|
||||
else:
|
||||
print(currentSystem)
|
||||
sys.exit(0)
|
||||
|
||||
def getBodyCount(system):
|
||||
try:
|
||||
bodyCount = System(system).bodyCount
|
||||
|
@ -56,6 +69,11 @@ parser_distance = subparsers.add_parser("distancebetween",
|
|||
+ "on EDSM.")
|
||||
parser_distance.add_argument("system", nargs=2)
|
||||
|
||||
parser_find = subparsers.add_parser("findCommander",
|
||||
help="Attempts to find a CMDR’s last known position. Will exit with code 1 "
|
||||
+ "on server error and code 2 if the CMDR could not be found on EDSM.")
|
||||
parser_find.add_argument("name")
|
||||
|
||||
argcomplete.autocomplete(parser)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -65,3 +83,5 @@ if args.subCommand == "bodycount":
|
|||
getBodyCount(args.system[0])
|
||||
elif args.subCommand == "distancebetween":
|
||||
distanceBetween(args.system[0], args.system[1])
|
||||
elif args.subCommand == "findCommander":
|
||||
findCommander(args.name)
|
||||
|
|
|
@ -27,8 +27,12 @@ cat >> README.md << EOF
|
|||
\`\`\`
|
||||
EOF
|
||||
./explorationtools.py distancebetween -h >> README.md
|
||||
cat >> README.md << EOF
|
||||
\`\`\`
|
||||
|
||||
|
||||
\`\`\`
|
||||
EOF
|
||||
./explorationtools.py findCommander -h >> README.md
|
||||
cat >> README.md << EOF
|
||||
\`\`\`
|
||||
EOF
|
||||
|
|
Loading…
Reference in a new issue