Skip to content

Commit 52ac5bb

Browse files
committed
update example name
1 parent a80891c commit 52ac5bb

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Upload Python Package to PyPI when a Release is Created
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
pypi-publish:
9+
name: Publish release to PyPI
10+
runs-on: ubuntu-latest
11+
environment:
12+
name: pypi
13+
url: https://pypi.org/p/pycot
14+
permissions:
15+
id-token: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.x"
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install setuptools wheel
26+
- name: Build package
27+
run: |
28+
python setup.py sdist bdist_wheel # Could also be python -m build
29+
- name: Publish package distributions to PyPI
30+
uses: pypa/gh-action-pypi-publish@release/v1
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
context.load_cert_chain(certfile='client_cert.pem', keyfile='client_key.pem')
3131

3232
# Connect to server
33-
hostname = 'x.x.x.x'
34-
port = 8089
33+
hostname = '134.199.213.125'
34+
port = 9009
3535

3636
def get_sar(mmsi: str) -> bool:
3737
"""Get the AIS Search-And-Rescue (SAR) status of a given MMSI.
@@ -56,7 +56,7 @@ def get_sar(mmsi: str) -> bool:
5656

5757
def create_cot_event(message: dict):
5858
now = datetime.datetime.now(datetime.timezone.utc)
59-
stale = now + datetime.timedelta(minutes=2)
59+
stale = now + datetime.timedelta(minutes=10)
6060

6161
print(message['Message']['PositionReport'])
6262
print(message)
@@ -78,7 +78,7 @@ def create_cot_event(message: dict):
7878
async def connect_ais_stream():
7979
async with websockets.connect("wss://stream.aisstream.io/v0/stream") as websocket:
8080
subscribe_message = {
81-
"APIKey": "",
81+
"APIKey": "4a98e66f38997bf8dc62226380434734886e4efb",
8282
"BoundingBoxes": [[[-90, -180], [90, 180]]],
8383
"FilteringMMSI": ["368207620", "367719770", "211476060"],
8484
"FilderingMessageTypes": ["PositionReport"]
@@ -99,10 +99,12 @@ async def connect_ais_stream():
9999
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
100100
ssock.sendall(b)
101101
data = ssock.recv(1024)
102+
await asyncio.sleep(1)
102103

103104

104-
def main():
105-
asyncio.run(asyncio.run(connect_ais_stream()))
106-
107105
if __name__ == "__main__":
108-
main()
106+
while True:
107+
try:
108+
asyncio.run(asyncio.run(connect_ais_stream()))
109+
except:
110+
continue

0 commit comments

Comments
 (0)