-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Samael500/dev
Dev
- Loading branch information
Showing
59 changed files
with
4,344 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
[report] | ||
omit = | ||
venv/* | ||
*/settings* | ||
*/python?.?/* | ||
*/site-packages/* | ||
|
||
sevboats/sb.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,7 @@ docs/_build/ | |
target/ | ||
|
||
# virtual env | ||
venv/ | ||
venv/ | ||
|
||
# settings local | ||
settings_local.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
test: | ||
. venv/bin/activate; nosetests --color --nologcapture sev-boats | ||
. venv/bin/activate; nosetests --color --nologcapture sevboats/ | ||
|
||
ci_test: | ||
nosetests --color --nologcapture --with-coverage sev-boats | ||
nosetests --with-coverage --cover-package=sevboats --color sevboats/ | ||
make pep8 | ||
make pyflakes | ||
|
||
pep8: | ||
pep8 --max-line-length=119 --show-source sev-boats/ | ||
pep8 --max-line-length=119 --show-source sevboats/ | ||
|
||
pyflakes: | ||
pylama -l pyflakes sev-boats/ | ||
pylama -l pyflakes sevboats/ | ||
|
||
install: | ||
mkdir venv | ||
virtualenv --no-site-packages --prompt="(sev-boats)" venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!venv/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import sys | ||
import traceback | ||
import logging | ||
from colorama import Fore | ||
from datetime import datetime | ||
from apscheduler.schedulers.blocking import BlockingScheduler | ||
|
||
import sevboats | ||
|
||
|
||
# init variables | ||
scheduler = BlockingScheduler() | ||
twitter = sevboats.Twitter() | ||
middaygun = sevboats.MiddayGun() | ||
ship_messenger = sevboats.ShipMessenger() | ||
|
||
date_format = '%Y-%m-%d %H:%M :' | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
# def functions | ||
|
||
|
||
def logger(function): | ||
|
||
def wrapper(): | ||
try: | ||
result = function() | ||
print Fore.BLUE, datetime.now().strftime(date_format), | ||
print Fore.GREEN, result['text'].replace('\n', ' - '), | ||
except Exception, e: | ||
print Fore.BLUE, datetime.now().strftime(date_format), | ||
print Fore.RED, e.message | ||
traceback.print_exc(file=sys.stdout) | ||
finally: | ||
print Fore.RESET | ||
return wrapper | ||
|
||
|
||
@scheduler.scheduled_job('cron', hour='12', minute='0', second='5', id='middaygun') | ||
@logger | ||
def middaygun_msg(): | ||
""" Post middaygun messages """ | ||
message = middaygun.get_message() | ||
print 'middaygun:', message | ||
return twitter.post_tweet(message) | ||
|
||
|
||
@scheduler.scheduled_job('cron', hour='6-22', minute='15,45', id='ship_status') | ||
@logger | ||
def ship_status_msg(): | ||
""" Post ship status messages """ | ||
now = datetime.now() | ||
minute = now.minute | ||
hour = now.hour | ||
status, change = sevboats.send_fleet_message() | ||
message = ship_messenger.get_message(status) | ||
if change or (not(hour % sevboats.settings.MESSAGE_PERIOD) and minute < 30): | ||
print 'ship status:', message | ||
return twitter.post_tweet(message) | ||
else: | ||
return dict(text=Fore.YELLOW + message) | ||
|
||
|
||
if __name__ == '__main__': | ||
# print (sys.argv) | ||
print 'Press Ctrl+C to exit' | ||
ship_status_msg() | ||
try: | ||
scheduler.start() | ||
except (KeyboardInterrupt, SystemExit): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
####################################################################################### | ||
# ______ _______ __ # | ||
# / \ | \ | \ # | ||
# | ######\ ______ __ __ | #######\ ______ ______ _| ##_ _______ # | ||
# | ##___\## / \ | \ / \| ##__/ ## / \ | \ | ## \ / \ # | ||
# \## \ | ######\ \##\ / ##| ## ##| ######\ \######\ \###### | ####### # | ||
# _\######\| ## ## \##\ ## | #######\| ## | ## / ## | ## __ \## \ # | ||
# | \__| ##| ######## \## ## | ##__/ ##| ##__/ ##| ####### | ##| \ _\######\ # | ||
# \## ## \## \ \### | ## ## \## ## \## ## \## ##| ## # | ||
# \###### \####### \# \####### \###### \####### \#### \####### # | ||
# # | ||
####################################################################################### | ||
""" | ||
|
||
from sevboats.settings import * # noqa | ||
from sevboats.src.twitter import Twitter # noqa | ||
from sevboats.src.messages import MiddayGun, ShipMessenger # noqa | ||
from sevboats.src.engine import initial, send_fleet_message # noqa | ||
|
||
initial() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> | ||
<Document> | ||
<name>Apolonovka.kml</name> | ||
<StyleMap id="msn_ylw-pushpin"> | ||
<Pair> | ||
<key>normal</key> | ||
<styleUrl>#sn_ylw-pushpin</styleUrl> | ||
</Pair> | ||
<Pair> | ||
<key>highlight</key> | ||
<styleUrl>#sh_ylw-pushpin</styleUrl> | ||
</Pair> | ||
</StyleMap> | ||
<Style id="sn_ylw-pushpin"> | ||
<IconStyle> | ||
<scale>1.1</scale> | ||
<Icon> | ||
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> | ||
</Icon> | ||
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> | ||
</IconStyle> | ||
<LineStyle> | ||
<color>ff00ffff</color> | ||
</LineStyle> | ||
</Style> | ||
<Style id="sh_ylw-pushpin"> | ||
<IconStyle> | ||
<scale>1.3</scale> | ||
<Icon> | ||
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> | ||
</Icon> | ||
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> | ||
</IconStyle> | ||
<LineStyle> | ||
<color>ff00ffff</color> | ||
</LineStyle> | ||
</Style> | ||
<Placemark> | ||
<name>Аполоновка</name> | ||
<open>1</open> | ||
<LookAt> | ||
<longitude>33.542318</longitude> | ||
<latitude>44.615819</latitude> | ||
<altitude>0</altitude> | ||
<heading>0</heading> | ||
<tilt>0</tilt> | ||
<range>300</range> | ||
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode> | ||
</LookAt> | ||
<styleUrl>#msn_ylw-pushpin</styleUrl> | ||
<LineString> | ||
<tessellate>1</tessellate> | ||
<coordinates> | ||
33.54215568619751,44.61593495355514,0 33.54197839892391,44.61591942523997,0 33.54182713457854,44.61637821912546,0 33.54208099832216,44.61647006060159,0 33.54228729590862,44.61647621562161,0 33.5424026157699,44.61606930643723,0 33.54215568619751,44.61593495355514,0 | ||
</coordinates> | ||
</LineString> | ||
</Placemark> | ||
</Document> | ||
</kml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> | ||
<Document> | ||
<name>Art buhta kater.kml</name> | ||
<Style id="sn_ylw-pushpin"> | ||
<IconStyle> | ||
<scale>1.1</scale> | ||
<Icon> | ||
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> | ||
</Icon> | ||
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> | ||
</IconStyle> | ||
<LineStyle> | ||
<color>ffff0000</color> | ||
</LineStyle> | ||
</Style> | ||
<Style id="sh_ylw-pushpin"> | ||
<IconStyle> | ||
<scale>1.3</scale> | ||
<Icon> | ||
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> | ||
</Icon> | ||
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> | ||
</IconStyle> | ||
<LineStyle> | ||
<color>ffff0000</color> | ||
</LineStyle> | ||
</Style> | ||
<StyleMap id="msn_ylw-pushpin"> | ||
<Pair> | ||
<key>normal</key> | ||
<styleUrl>#sn_ylw-pushpin</styleUrl> | ||
</Pair> | ||
<Pair> | ||
<key>highlight</key> | ||
<styleUrl>#sh_ylw-pushpin</styleUrl> | ||
</Pair> | ||
</StyleMap> | ||
<Placemark> | ||
<name>Арт бухта катер</name> | ||
<LookAt> | ||
<longitude>33.518858</longitude> | ||
<latitude>44.61311</latitude> | ||
<altitude>0</altitude> | ||
<heading>0</heading> | ||
<tilt>0</tilt> | ||
<range>300</range> | ||
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode> | ||
</LookAt> | ||
<styleUrl>#msn_ylw-pushpin</styleUrl> | ||
<LineString> | ||
<tessellate>1</tessellate> | ||
<coordinates> | ||
33.51927340441577,44.61394406109425,0 33.51934909367381,44.61393708861851,0 33.51945524980726,44.61386052260114,0 33.51943346080763,44.61379167988019,0 33.51924309058395,44.61363210714139,0 33.51914869204065,44.61361602447229,0 33.51901379607199,44.61368287049788,0 33.51903034106027,44.61375534060404,0 33.51909824430913,44.61381863186332,0 33.51927340441577,44.61394406109425,0 | ||
</coordinates> | ||
</LineString> | ||
</Placemark> | ||
</Document> | ||
</kml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> | ||
<Document> | ||
<name>Art buhta parom.kml</name> | ||
<Style id="sh_ylw-pushpin"> | ||
<IconStyle> | ||
<scale>1.3</scale> | ||
<Icon> | ||
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> | ||
</Icon> | ||
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> | ||
</IconStyle> | ||
<LineStyle> | ||
<color>ff00ff00</color> | ||
</LineStyle> | ||
</Style> | ||
<Style id="sn_ylw-pushpin"> | ||
<IconStyle> | ||
<scale>1.1</scale> | ||
<Icon> | ||
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> | ||
</Icon> | ||
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/> | ||
</IconStyle> | ||
<LineStyle> | ||
<color>ff00ff00</color> | ||
</LineStyle> | ||
</Style> | ||
<StyleMap id="msn_ylw-pushpin"> | ||
<Pair> | ||
<key>normal</key> | ||
<styleUrl>#sn_ylw-pushpin</styleUrl> | ||
</Pair> | ||
<Pair> | ||
<key>highlight</key> | ||
<styleUrl>#sh_ylw-pushpin</styleUrl> | ||
</Pair> | ||
</StyleMap> | ||
<Placemark> | ||
<name>Арт бухта паром</name> | ||
<open>1</open> | ||
<LookAt> | ||
<longitude>33.518858</longitude> | ||
<latitude>44.61311</latitude> | ||
<altitude>0</altitude> | ||
<heading>0</heading> | ||
<tilt>0</tilt> | ||
<range>300</range> | ||
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode> | ||
</LookAt> | ||
<styleUrl>#msn_ylw-pushpin</styleUrl> | ||
<LineString> | ||
<tessellate>1</tessellate> | ||
<coordinates> | ||
33.51890122387751,44.61409771417932,0 33.51901800038457,44.61419461208305,0 33.51921290598291,44.61406973565808,0 33.51922975838581,44.61404609156869,0 33.51920159414065,44.61399479120338,0 33.51904589690794,44.61385651698006,0 33.51891873084674,44.6137273954934,0 33.51881216850742,44.61374348963695,0 33.51862562811535,44.61383417315219,0 33.51869892536574,44.61392620855101,0 33.51890122387751,44.61409771417932,0 | ||
</coordinates> | ||
</LineString> | ||
</Placemark> | ||
</Document> | ||
</kml> |
Oops, something went wrong.