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 ##
|
## explorationtools.py ##
|
||||||
|
|
||||||
```
|
```
|
||||||
usage: explorationtools.py [-h] {bodycount,distancebetween} ...
|
usage: explorationtools.py [-h] {bodycount,distancebetween,findCommander} ...
|
||||||
|
|
||||||
A collection of tools useful for exploration.
|
A collection of tools useful for exploration.
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
|
|
||||||
subcommands:
|
subcommands:
|
||||||
{bodycount,distancebetween}
|
{bodycount,distancebetween,findCommander}
|
||||||
sub-command help
|
sub-command help
|
||||||
bodycount Returns the number of bodies in a system. Will exit
|
bodycount Returns the number of bodies in a system. Will exit
|
||||||
with code 1 on server error and code 2 if the system
|
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
|
distancebetween Calculates the distance between two systems. Will exit
|
||||||
with code 1 on server error and code 2 if (one of) the
|
with code 1 on server error and code 2 if (one of) the
|
||||||
systems could not be found on EDSM.
|
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:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-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)))
|
+ (coords1['z']-coords2['z'])**2 ),0)))
|
||||||
sys.exit(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):
|
def getBodyCount(system):
|
||||||
try:
|
try:
|
||||||
bodyCount = System(system).bodyCount
|
bodyCount = System(system).bodyCount
|
||||||
|
@ -56,6 +69,11 @@ parser_distance = subparsers.add_parser("distancebetween",
|
||||||
+ "on EDSM.")
|
+ "on EDSM.")
|
||||||
parser_distance.add_argument("system", nargs=2)
|
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)
|
argcomplete.autocomplete(parser)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -65,3 +83,5 @@ if args.subCommand == "bodycount":
|
||||||
getBodyCount(args.system[0])
|
getBodyCount(args.system[0])
|
||||||
elif args.subCommand == "distancebetween":
|
elif args.subCommand == "distancebetween":
|
||||||
distanceBetween(args.system[0], args.system[1])
|
distanceBetween(args.system[0], args.system[1])
|
||||||
|
elif args.subCommand == "findCommander":
|
||||||
|
findCommander(args.name)
|
||||||
|
|
|
@ -27,8 +27,12 @@ cat >> README.md << EOF
|
||||||
\`\`\`
|
\`\`\`
|
||||||
EOF
|
EOF
|
||||||
./explorationtools.py distancebetween -h >> README.md
|
./explorationtools.py distancebetween -h >> README.md
|
||||||
|
cat >> README.md << EOF
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
\`\`\`
|
||||||
|
EOF
|
||||||
|
./explorationtools.py findCommander -h >> README.md
|
||||||
cat >> README.md << EOF
|
cat >> README.md << EOF
|
||||||
\`\`\`
|
\`\`\`
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in a new issue