コード例 #1
0
    return script_stats


def update_stats(script_stats):
    script_stats['running_count'] = 0
    script_stats['processed_requests'] = processed_requests
    script_stats['last_completed_at'] = datetime.now().strftime(
        '%A, %d. %B %Y %H:%M:%S')
    db.scriptstats.save(script_stats)


if __name__ == '__main__':
    endpoints = ['bloomington', 'baltimore', 'boston']
    lm = LogManager()
    logger = lm.logger
    connection = Connection(os.environ['MONGO_URI'])
    db = connection[os.environ['MONGO_DATABASE']]
    while (True):
        for endpoint in endpoints:
            processed_requests = 0
            script_stats = increment_running_count_in_stats()
            logger.info('downloading requests from {0}...'.format(endpoint))
            city = three.city(endpoint)
            download_requests()
            logger.info('setting geospatial index on loc field')
            db.requests.ensure_index([("loc", GEO2D)])
            mark_requests_with_boundaries()
            update_stats(script_stats)
        logger.debug('requests downloaded; sleeping for 1 hour')
        sleep(3600)
コード例 #2
0
ファイル: test.py プロジェクト: siruguri/three
 def test_three_city_info(self):
     three.city("sf")
     info = os.environ["OPEN311_CITY_INFO"]
     self.assertTrue(info)
コード例 #3
0
ファイル: test.py プロジェクト: isabella232/three
 def test_three_services(self):
     three.city('sf')
     three.services()
     self.assertTrue(self.session.get.called)
コード例 #4
0
ファイル: sms.py プロジェクト: FaisalNahian/message_macon
"""SMSified logic for the MTA application."""

import os
import requests as req
import three


if 'PRODUCTION_ENV' in os.environ:
    # Then we'll use the actual SeeClickFix endpoint.
    macon = three.city('macon')
else:
    # Otherwise, it's testing.
    macon = three.dev('http://seeclicktest.com/open311/v2')


class AddressError(Exception):
    """Can't parse an address from a text message."""
    pass


class AuthenticationError(Exception):
    """
    Error should be raised when the SMSified username and password
    aren't known.
    """
    pass


def auth():
    """
    Get SMSified username and password authentication from environment
コード例 #5
0
    script_stats['last_started_at'] = datetime.now().strftime('%A, %d. %B %Y %H:%M:%S')
    logger.debug(script_stats)
    db.scriptstats.save(script_stats)
    return script_stats

def update_stats(script_stats):
    script_stats['running_count'] = 0
    script_stats['processed_requests'] = processed_requests 
    script_stats['last_completed_at'] = datetime.now().strftime('%A, %d. %B %Y %H:%M:%S')
    db.scriptstats.save(script_stats)

if __name__ == '__main__':
    endpoints = ['bloomington', 'baltimore', 'boston']
    lm = LogManager()
    logger = lm.logger
    connection = Connection(os.environ['MONGO_URI'])
    db = connection[os.environ['MONGO_DATABASE']]
    while(True):
        for endpoint in endpoints:
            processed_requests = 0
            script_stats = increment_running_count_in_stats()
            logger.info('downloading requests from {0}...'.format(endpoint))
            city = three.city(endpoint)
            download_requests()
            logger.info('setting geospatial index on loc field')
            db.requests.ensure_index([("loc", GEO2D)])
            mark_requests_with_boundaries() 
            update_stats(script_stats)
        logger.debug('requests downloaded; sleeping for 1 hour')
        sleep(3600)
コード例 #6
0
ファイル: test.py プロジェクト: isabella232/three
 def test_three_request_specific_report(self):
     three.city('macon')
     three.request('123abc')
     self.assertTrue(self.session.get.called)
コード例 #7
0
ファイル: test.py プロジェクト: isabella232/three
 def test_three_city_info(self):
     three.city('sf')
     info = os.environ['OPEN311_CITY_INFO']
     self.assertTrue(info)
コード例 #8
0
ファイル: test.py プロジェクト: siruguri/three
 def test_three_request_specific_report(self):
     three.city("macon")
     three.request("123abc")
     self.assertTrue(req.get.called)
コード例 #9
0
ファイル: test.py プロジェクト: SeeClickFix/three
 def test_three_request_specific_report(self):
     three.city('macon')
     three.request('123abc')
     self.assertTrue(self.session.get.called)
コード例 #10
0
ファイル: test.py プロジェクト: SeeClickFix/three
 def test_three_services(self):
     three.city('sf')
     three.services()
     self.assertTrue(self.session.get.called)
コード例 #11
0
ファイル: test.py プロジェクト: SeeClickFix/three
 def test_three_requests(self):
     three.city('macon')
     three.requests()
     self.assertTrue(self.session.get.called)
コード例 #12
0
ファイル: test.py プロジェクト: SeeClickFix/three
 def test_three_discovery(self):
     three.city('new haven')
     three.discovery()
     self.assertTrue(self.session.get.called)
コード例 #13
0
ファイル: test.py プロジェクト: SeeClickFix/three
 def test_three_city_info(self):
     three.city('sf')
     info = os.environ['OPEN311_CITY_INFO']
     self.assertTrue(info)
コード例 #14
0
ファイル: test.py プロジェクト: siruguri/three
 def test_three_discovery(self):
     three.city("new haven")
     three.discovery()
     self.assertTrue(req.get.called)
コード例 #15
0
ファイル: test.py プロジェクト: isabella232/three
 def test_three_discovery(self):
     three.city('new haven')
     three.discovery()
     self.assertTrue(self.session.get.called)
コード例 #16
0
ファイル: test.py プロジェクト: siruguri/three
 def test_three_requests(self):
     three.city("macon")
     three.requests()
     self.assertTrue(req.get.called)
コード例 #17
0
ファイル: test.py プロジェクト: isabella232/three
 def test_three_requests(self):
     three.city('macon')
     three.requests()
     self.assertTrue(self.session.get.called)
コード例 #18
0
ファイル: test.py プロジェクト: siruguri/three
 def test_three_services(self):
     three.city("sf")
     three.services()
     self.assertTrue(req.get.called)
コード例 #19
0
ファイル: sms.py プロジェクト: isabella232/message_macon
"""SMSified logic for the MTA application."""

import os
import requests as req
import three

if 'PRODUCTION_ENV' in os.environ:
    # Then we'll use the actual SeeClickFix endpoint.
    macon = three.city('macon')
else:
    # Otherwise, it's testing.
    macon = three.dev('http://seeclicktest.com/open311/v2')


class AddressError(Exception):
    """Can't parse an address from a text message."""
    pass


class AuthenticationError(Exception):
    """
    Error should be raised when the SMSified username and password
    aren't known.
    """
    pass


def auth():
    """
    Get SMSified username and password authentication from environment
    variables.