Skip to content

Commit

Permalink
Merge pull request #4 from Samael500/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
samael500 committed Feb 28, 2015
2 parents 65c7e11 + 49f1133 commit e28bdf3
Show file tree
Hide file tree
Showing 59 changed files with 4,344 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[report]
omit =
venv/*
*/settings*
*/python?.?/*
*/site-packages/*

sevboats/sb.py
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ docs/_build/
target/

# virtual env
venv/
venv/

# settings local
settings_local.py
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ python:
- 2.7
install: pip install -r requirements.txt
script: make ci_test
after_success:
after_script:
- coveralls
12 changes: 8 additions & 4 deletions Makefile
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
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,3 @@ Sevastopol Boats [Twitter](https://twitter.com/SevastopolBoats)
=
[![Build Status](https://travis-ci.org/Samael500/sev-boats.svg?branch=master)](https://travis-ci.org/Samael500/sev-boats)
[![Coverage Status](https://coveralls.io/repos/Samael500/sev-boats/badge.png)](https://coveralls.io/r/Samael500/sev-boats)

###Requirements
* venv

###Venv
```bash
$ mkdir venv
$ virtualenv --no-site-packages --prompt="(sev-boats)" venv
```

76 changes: 76 additions & 0 deletions manage.py
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
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ termcolor==1.1.0
pep8==1.5.7
pylama==6.0.1
coveralls==0.4.2
twython==3.1.2
beautifulsoup4==4.3.2
APScheduler==3.0.1
colorama==0.3.2
21 changes: 21 additions & 0 deletions sevboats/__init__.py
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()
60 changes: 60 additions & 0 deletions sevboats/data/bay/Apolonovka.kml
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>
59 changes: 59 additions & 0 deletions sevboats/data/bay/Art buhta kater.kml
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>
60 changes: 60 additions & 0 deletions sevboats/data/bay/Art buhta parom.kml
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>
Loading

0 comments on commit e28bdf3

Please sign in to comment.