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
"""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
    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
"""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.