mirror of
https://github.com/cwinfo/hyperboria-peers.git
synced 2024-11-25 03:11:38 +00:00
commit
403bb4dcf2
6
.travis.yml
Normal file
6
.travis.yml
Normal file
@ -0,0 +1,6 @@
|
||||
sudo: false
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- python3
|
||||
script: ./tests.py
|
@ -2,6 +2,5 @@
|
||||
"password":"public-20150903-6pb6aEKDDKVr9zsBJIyDUYfrXYzQv1",
|
||||
"publicKey":"s680fh7g69ww3y9cmrxt910u5hvrwrmcnln1sz6mq1jk5mquq8k0.k",
|
||||
"user":"katt",
|
||||
"contact":"oniichan@mrowr.me",
|
||||
"contact":"oniichan@mrowr.me"
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,5 @@
|
||||
"password":"ALcVwciz1enkZTE1SvBjj7WX2gZwtcTa",
|
||||
"publicKey":"bddc5j6sc45hlrdnccu120zwnmm2z0qlbfkxn9n8xbs0vqgx9fh0.k",
|
||||
"user":"ansuz",
|
||||
"contact":"ansuz@transitiontech.ca",
|
||||
"contact":"ansuz@transitiontech.ca"
|
||||
}
|
||||
|
||||
|
@ -65,10 +65,7 @@ By following this scheme, we make it possible for users to programmatically find
|
||||
```
|
||||
|
||||
> Note: the snippet above is **not valid json**. It would need to be wrapped in an additional block of curly braces `{ }`
|
||||
>
|
||||
> We will create a linter that validates such blocks (coming soon).
|
||||
|
||||
## Naming your entry
|
||||
|
||||
You can name your file whatever you want, but for simplicity's sake, avoid characters which will need to be escaped at the command line.
|
||||
|
||||
|
40
tests.py
Executable file
40
tests.py
Executable file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
REQUIRED_FIELDS = ['publicKey', 'password', 'contact']
|
||||
|
||||
|
||||
RED = '\x1b[01;31m'
|
||||
GREEN = '\x1b[01;32m'
|
||||
END = '\x1b[0m'
|
||||
|
||||
|
||||
def validate(path):
|
||||
print("Validating %s" % path)
|
||||
try:
|
||||
creds = open(path).read()
|
||||
peers = json.loads("{%s}" % creds)
|
||||
hosts = peers.keys()
|
||||
for host in hosts:
|
||||
for field in REQUIRED_FIELDS:
|
||||
if not field in peers[host]:
|
||||
print(" %sHost %s is missing the %s field!%s" % (RED, host, field, END))
|
||||
return False
|
||||
print(" %sSuccess!%s" % (GREEN, END))
|
||||
return True
|
||||
except ValueError:
|
||||
print(" %sInvalid JSON!%s" % (RED, END))
|
||||
return False
|
||||
|
||||
success = True
|
||||
for directory, subdirs, files in os.walk('.'):
|
||||
if len(files) > 0:
|
||||
for f in files:
|
||||
if f.endswith('.k'):
|
||||
result = validate("%s/%s" % (directory, f))
|
||||
if not result:
|
||||
success = False
|
||||
if not success:
|
||||
sys.exit(1)
|
Loading…
Reference in New Issue
Block a user