コード例 #1
0
ファイル: jabber.py プロジェクト: kfakhri1/GarageSecurity
  def receive(self, message):
    if message['type'] in ('chat', 'normal'):
      logger.debug("XMPP Message: %s" % message)
      from_account = "%s@%s" % (message['from'].user, message['from'].domain)
      logger.info("Received message from %s" % from_account)

      if not from_account in configuration.get('xmpp_recipients'):
        logger.warn("Received message from non-whitelist user %s: %s" % (from_account, message['body']))
      elif "%s camera" % self.instance_name in message['body'].lower():
        image_bin = self.camera.get_image()
        image_url = self.bucket.upload(image_bin)
        message.reply("Status: %s" % image_url).send()
      elif "%s lastevent" % self.instance_name in message['body'].lower():
        archive_dir = configuration.get('webcam_archive')
        time_struct = max(map(lambda x: os.path.getmtime("%s/%s" % (archive_dir, x)), os.listdir(archive_dir)))
        message.reply("Last Event: %s" % time.strftime("%c", time.localtime(time_struct))).send()
      elif "%s climate" % self.instance_name in message['body'].lower():
        humidity, celsius, status = self.temperature.get_conditions()
        farenheit = ((celsius * 9) / 5) + 32
        message.reply("Temperature: %0.2fF, Humidity: %0.2f%%" % (farenheit, humidity)).send()
      elif "%s silent" % self.instance_name in message['body'].lower():
        self.silent = True
        message.reply("Silencing alerts").send()
      elif "%s audible" % self.instance_name in message['body'].lower():
        self.silent = False
        message.reply("Enabling alerts").send()
      else:
        logger.info("Uncaught command from %s: %s" % (from_account, message['body']))
コード例 #2
0
def show_status():
    archive_dir = configuration.get('webcam_archive')
    archive_dir = configuration.get('webcam_archive')
    time_struct = max(
        map(lambda x: os.path.getmtime("%s/%s" % (archive_dir, x)),
            os.listdir(archive_dir)))
    return '{ "last_area_detected": "%s" }' % time.strftime(
        "%c", time.localtime(time_struct))
コード例 #3
0
ファイル: upgrade.py プロジェクト: A-Gut/odoo_addons
 def _get_upgrades(self):
     upgrades_path = upgrade_config.get('upgrades_path')
     if self.db_in_creation or not upgrades_path:
         return []
     upgrades = []
     for dir in os.listdir(upgrades_path):
         dir_path = os.path.join(upgrades_path, dir)
         if os.path.isdir(dir_path):
             file_path = os.path.join(dir_path, '__upgrade__.py')
             if not os.path.exists(file_path):
                 _logger.warning(u"%s doesn't exist", file_path)
                 continue
             if not os.path.isfile(file_path):
                 _logger.warning(u'%s is not a file', file_path)
                 continue
             with open(file_path) as f:
                 try:
                     upgrade_infos = eval(f.read())
                     upgrade = Upgrade(self.db, dir_path, upgrade_infos)
                     if (not upgrade.databases or self.db_name in upgrade.databases) \
                             and self.db_version < upgrade.version <= self.code_version:
                         upgrades.append(upgrade)
                 except:
                     _logger.error('%s is not valid', file_path)
     return sorted(upgrades, key=lambda upgrade: upgrade.version)
コード例 #4
0
def get_lastevent(jabber):
    archive_dir = configuration.get('webcam_archive')
    time_struct = max(
        map(lambda x: os.path.getmtime("%s/%s" % (archive_dir, x)),
            os.listdir(archive_dir)))
    return '{ "datetime": "%s" }' % time.strftime("%c",
                                                  time.localtime(time_struct))
コード例 #5
0
ファイル: upgrade.py プロジェクト: A-Gut/odoo_addons
 def _get_code_version(self):
     version = upgrade_config.get('version')
     if not version:
         _logger.warning(
             'Unspecified version in upgrades configuration file')
     _logger.debug('code version: %s', version)
     return version
コード例 #6
0
 def _get_upgrades(self):
     upgrades_path = upgrade_config.get('upgrades_path')
     if self.db_in_creation or not upgrades_path:
         return []
     upgrades = []
     for dir in os.listdir(upgrades_path):
         dir_path = os.path.join(upgrades_path, dir)
         if os.path.isdir(dir_path):
             file_path = os.path.join(dir_path, '__upgrade__.py')
             if not os.path.exists(file_path):
                 _logger.warning(u"%s doesn't exist", file_path)
                 continue
             if not os.path.isfile(file_path):
                 _logger.warning(u'%s is not a file', file_path)
                 continue
             with open(file_path) as f:
                 try:
                     upgrade_infos = eval(f.read())
                     upgrade = Upgrade(self.db, dir_path, upgrade_infos)
                     if (not upgrade.databases or self.db_name in upgrade.databases) \
                             and self.db_version < upgrade.version <= self.code_version:
                         upgrades.append(upgrade)
                 except:
                     _logger.error('%s is not valid', file_path)
     return sorted(upgrades, key=lambda upgrade: upgrade.version)
コード例 #7
0
 def _get_upgrades(self):
     upgrades_path = upgrade_config.get('upgrades_path')
     if not upgrades_path:
         return []
     if not self.db_in_creation:
         self._try_lock('Upgrade in progress')
     upgrades = []
     for dir in os.listdir(upgrades_path):
         dir_path = os.path.join(upgrades_path, dir)
         if os.path.isdir(dir_path):
             file_path = os.path.join(dir_path, '__upgrade__.py')
             if not os.path.exists(file_path):
                 _logger.warning(u"%s doesn't exist", file_path)
                 continue
             if not os.path.isfile(file_path):
                 _logger.warning(u'%s is not a file', file_path)
                 continue
             with open(file_path) as f:
                 try:
                     upgrade_infos = eval(f.read())
                     upgrade = Upgrade(dir_path, upgrade_infos)
                     if (not upgrade.databases or self.db_name in upgrade.databases) \
                             and self.db_version < upgrade.version <= self.code_version:
                         upgrades.append(upgrade)
                 except Exception, e:
                     _logger.error('%s is not valid: %s', file_path,
                                   repr(e))
コード例 #8
0
ファイル: s3.py プロジェクト: deckerego/GarageSecurity
    def upload(self, image):
        entry = Key(self.bucket)
        entry.key = "%s.jpg" % self.instance_name
        entry.set_contents_from_string(image)

        url = entry.generate_url(configuration.get('s3_url_expiry'))
        entry.copy(entry.bucket.name, entry.name, {'Content-Type':'image/jpeg'}, preserve_acl=True)
        return url
コード例 #9
0
  def setup(self, app):
    self.routes = app

    for other in app.plugins:
      if not isinstance(other, Jabber):
        continue
      if other.keyword == self.keyword:
        raise PluginError("Found another instance of Jabber running!")

    host = configuration.get('xmpp_server_host')
    port = configuration.get('xmpp_server_port')

    if self.connect((host, port)):
      logger.info("Opened XMPP Connection")
      self.process(block=False)
    else:
      raise Exception("Unable to connect to Google Jabber server")
コード例 #10
0
    def setup(self, app):
        self.routes = app

        for other in app.plugins:
            if not isinstance(other, Jabber):
                continue
            if other.keyword == self.keyword:
                raise PluginError("Found another instance of Jabber running!")

        host = configuration.get('xmpp_server_host')
        port = configuration.get('xmpp_server_port')

        if self.connect((host, port)):
            logger.info("Opened XMPP Connection")
            self.process(block=False)
        else:
            raise Exception("Unable to connect to Google Jabber server")
コード例 #11
0
ファイル: routes.py プロジェクト: deckerego/GarageSecurity
def movie_end(media):
	motion_event = request.json
	video_file_path = motion_event['file']
	video_file_dir = os.path.dirname(video_file_path)

	if video_file_dir.index(configuration.get('webcam_archive')) == 0:
		media.transcode(video_file_path)

	return request.body.getvalue()
コード例 #12
0
ファイル: jabber.py プロジェクト: kfakhri1/GarageSecurity
  def __init__(self, jid, password, camera, temperature):
    super(Jabber, self).__init__(jid, password)

    self.camera = camera
    self.temperature = temperature
    self.instance_name = configuration.get('instance_name').lower()
    self.silent = False
    self.add_event_handler('session_start', self.start, threaded=False, disposable=True)
    self.add_event_handler('message', self.receive, threaded=True, disposable=False)
コード例 #13
0
def movie_end(media):
    motion_event = request.json
    video_file_path = motion_event['file']
    video_file_dir = os.path.dirname(video_file_path)

    if video_file_dir.index(configuration.get('webcam_archive')) == 0:
        media.transcode(video_file_path)

    return request.body.getvalue()
コード例 #14
0
ファイル: media.py プロジェクト: deckerego/GarageSecurity
    def __threaded_transcode(self, file_path):
        sourcefile = os.path.basename(file_path)
        filename = sourcefile[:-4]
        dirname = os.path.dirname(file_path)
        dest_file = "%s/%s.webm" % (dirname, filename)

        if dirname.index(configuration.get('webcam_archive')) == 0 and self.is_valid_source(sourcefile):
            subprocess.check_call(["avconv", "-i", file_path, "-vcodec", "vp8", "-an", dest_file])
            os.remove(file_path)
コード例 #15
0
ファイル: media.py プロジェクト: deckerego/GarageSecurity
    def save_thumbnail(self, file_path):
        sourcefile = os.path.basename(file_path)
        filename = sourcefile[:-4]
        dirname = os.path.dirname(file_path)

        if dirname.index(configuration.get('webcam_archive')) == 0 and self.is_valid_source(sourcefile):
            image = Image.open(file_path)
            image.thumbnail((640,360), Image.NEAREST)
            image.save("%s/%s.thumb.jpg" % (dirname, filename))
コード例 #16
0
    def send_alert_msg(self, body):
        if not self.silent:
            for recipient in configuration.get('xmpp_recipients'):
                message = self.Message()
                message['to'] = recipient
                message['type'] = 'chat'
                message['body'] = body

                logger.debug("Sending message: %s" % message)
                message.send()
コード例 #17
0
ファイル: media.py プロジェクト: plasmacorral/GarageSecurity
    def save_thumbnail(self, file_path):
        sourcefile = os.path.basename(file_path)
        filename = sourcefile[:-4]
        dirname = os.path.dirname(file_path)

        if dirname.index(configuration.get(
                'webcam_archive')) == 0 and self.is_valid_source(sourcefile):
            image = Image.open(file_path)
            image.thumbnail((640, 360), Image.NEAREST)
            image.save("%s/%s.thumb.jpg" % (dirname, filename))
コード例 #18
0
ファイル: jabber.py プロジェクト: kfakhri1/GarageSecurity
  def send_alert_msg(self, body):
    if not self.silent:
        for recipient in configuration.get('xmpp_recipients'):
          message = self.Message()
          message['to'] = recipient
          message['type'] = 'chat'
          message['body'] = body

          logger.debug("Sending message: %s" % message)
          message.send()
コード例 #19
0
    def upload(self, image):
        entry = Key(self.bucket)
        entry.key = "%s.jpg" % self.instance_name
        entry.set_contents_from_string(image)

        url = entry.generate_url(configuration.get('s3_url_expiry'))
        entry.copy(entry.bucket.name,
                   entry.name, {'Content-Type': 'image/jpeg'},
                   preserve_acl=True)
        return url
コード例 #20
0
ファイル: routes.py プロジェクト: deckerego/GarageSecurity
def picture_save(jabber, media):
	motion_event = request.json
	image_file_path = motion_event['file']
	image_file_dir = os.path.dirname(image_file_path)

	jabber.send_alert_image(image_file_path)

	if image_file_dir.index(configuration.get('webcam_archive')) == 0:
		media.save_thumbnail(image_file_path)

	return request.body.getvalue()
コード例 #21
0
def picture_save(jabber, media):
    motion_event = request.json
    image_file_path = motion_event['file']
    image_file_dir = os.path.dirname(image_file_path)

    jabber.send_alert_image(image_file_path)

    if image_file_dir.index(configuration.get('webcam_archive')) == 0:
        media.save_thumbnail(image_file_path)

    return request.body.getvalue()
コード例 #22
0
ファイル: media.py プロジェクト: plasmacorral/GarageSecurity
    def __threaded_transcode(self, file_path):
        sourcefile = os.path.basename(file_path)
        filename = sourcefile[:-4]
        dirname = os.path.dirname(file_path)
        dest_file = "%s/%s.webm" % (dirname, filename)

        if dirname.index(configuration.get(
                'webcam_archive')) == 0 and self.is_valid_source(sourcefile):
            subprocess.check_call([
                "avconv", "-i", file_path, "-vcodec", "vp8", "-an", dest_file
            ])
            os.remove(file_path)
コード例 #23
0
    def receive(self, message):
        if message['type'] in ('chat', 'normal'):
            logger.debug("XMPP Message: %s" % message)
            from_account = "%s@%s" % (message['from'].user,
                                      message['from'].domain)
            logger.info("Received message from %s" % from_account)

            if not from_account in configuration.get('xmpp_recipients'):
                logger.warn("Received message from non-whitelist user %s: %s" %
                            (from_account, message['body']))
            elif "%s camera" % self.instance_name in message['body'].lower():
                image_bin = self.camera.get_image()
                image_url = self.bucket.upload(image_bin)
                message.reply("Status: %s" % image_url).send()
            elif "%s lastevent" % self.instance_name in message['body'].lower(
            ):
                archive_dir = configuration.get('webcam_archive')
                time_struct = max(
                    map(lambda x: os.path.getmtime("%s/%s" % (archive_dir, x)),
                        os.listdir(archive_dir)))
                message.reply(
                    "Last Event: %s" %
                    time.strftime("%c", time.localtime(time_struct))).send()
            elif "%s climate" % self.instance_name in message['body'].lower():
                humidity, celsius, status = self.temperature.get_conditions()
                farenheit = ((celsius * 9) / 5) + 32
                message.reply("Temperature: %0.2fF, Humidity: %0.2f%%" %
                              (farenheit, humidity)).send()
            elif "%s silent" % self.instance_name in message['body'].lower():
                self.silent = True
                message.reply("Silencing alerts").send()
            elif "%s audible" % self.instance_name in message['body'].lower():
                self.silent = False
                message.reply("Enabling alerts").send()
            else:
                logger.info("Uncaught command from %s: %s" %
                            (from_account, message['body']))
コード例 #24
0
    def __init__(self, jid, password, temperature):
        super(Jabber, self).__init__(jid, password)

        self.temperature = temperature
        self.instance_name = configuration.get('instance_name').lower()
        self.silent = False
        self.sprinkler_button = 0
        self.add_event_handler('session_start',
                               self.start,
                               threaded=False,
                               disposable=True)
        self.add_event_handler('message',
                               self.receive,
                               threaded=True,
                               disposable=False)
コード例 #25
0
ファイル: media.py プロジェクト: deckerego/GarageSecurity
    def get_files(self, archive_date):
    	if not self.is_valid_date(archive_date):
    		raise ValueError('Archive dates must be in ISO format yyyy-mm-dd')

    	archive_dir = "%s/%s" % (configuration.get('webcam_archive'), archive_date)
    	dirpath, dirnames, filenames = next(os.walk(archive_dir))

    	image_files = filter(lambda f: self.is_valid_image(f), filenames)
        image_files = sorted(image_files, key=lambda f: f[:6])

    	video_files = filter(lambda f: self.is_valid_video(f), filenames)
        video_files = sorted(video_files, key=lambda f: f[:6])

        # FIXME Undefined behavior if we don't have matching video files for each image file
        return zip(image_files, video_files)
コード例 #26
0
ファイル: media.py プロジェクト: plasmacorral/GarageSecurity
    def get_files(self, archive_date):
        if not self.is_valid_date(archive_date):
            raise ValueError('Archive dates must be in ISO format yyyy-mm-dd')

        archive_dir = "%s/%s" % (configuration.get('webcam_archive'),
                                 archive_date)
        dirpath, dirnames, filenames = next(os.walk(archive_dir))

        image_files = filter(lambda f: self.is_valid_image(f), filenames)
        image_files = sorted(image_files, key=lambda f: f[:6])

        video_files = filter(lambda f: self.is_valid_video(f), filenames)
        video_files = sorted(video_files, key=lambda f: f[:6])

        # FIXME Undefined behavior if we don't have matching video files for each image file
        return zip(image_files, video_files)
コード例 #27
0
  def receive(self, message):
    if message['type'] in ('chat', 'normal'):
      logger.debug("XMPP Message: %s" % message)
      from_account = "%s@%s" % (message['from'].user, message['from'].domain)
      logger.info("Received message from %s" % from_account)

      if not from_account in configuration.get('xmpp_recipients'):
        logger.warn("Received message from non-whitelist user %s: %s" % (from_account, message['body']))
      elif "%s status" % self.instance_name in message['body'].lower():
        message.reply("Sprinkler is %s" % ("enabled" if self.gpio.is_enabled(self.sprinkler_button) else "disabled")).send()
      elif "%s climate" % self.instance_name in message['body'].lower():
        humidity, celsius, status = self.temperature.get_conditions()
        farenheit = ((celsius * 9) / 5) + 32
        message.reply("Temperature: %0.2fF, Humidity: %0.2f%%" % (farenheit, humidity)).send()
      else:
        logger.info("Uncaught command from %s: %s" % (from_account, message['body']))
コード例 #28
0
ファイル: GStreamer.py プロジェクト: DakotaHoosier/hack-clock
    def playList(self, fileNames):
        if not self.isPlaying():
            # Create a queue of URIs
            audio_dir = configuration.get('audio_files')
            self.playlist = [ "file://"+os.path.abspath("%s/%s" % (audio_dir, fileName)) for fileName in fileNames ]
            self.playlist.reverse()

            # Create the pipeline
            self.pl = gst.element_factory_make("playbin2", "player")
            self.pl.set_state(gst.STATE_READY)

            # Create the event bus
            self.bus = self.pl.get_bus()
            self.bus.add_signal_watch()
            self.bus.connect("message", self.onMessage)
            self.eventLoop = GtkEventLoop()
            self.eventLoop.start()

            # Play next track on playlist
            self.next()
コード例 #29
0
    def receive(self, message):
        if message['type'] in ('chat', 'normal'):
            logger.debug("XMPP Message: %s" % message)
            from_account = "%s@%s" % (message['from'].user,
                                      message['from'].domain)
            logger.info("Received message from %s" % from_account)

            if not from_account in configuration.get('xmpp_recipients'):
                logger.warn("Received message from non-whitelist user %s: %s" %
                            (from_account, message['body']))
            elif "%s status" % self.instance_name in message['body'].lower():
                message.reply(
                    "Sprinkler is %s" % ("enabled" if gpio.is_enabled(
                        self.sprinkler_button) else "disabled")).send()
            elif "%s climate" % self.instance_name in message['body'].lower():
                humidity, celsius, status = self.temperature.get_conditions()
                farenheit = ((celsius * 9) / 5) + 32
                message.reply("Temperature: %0.2fF, Humidity: %0.2f%%" %
                              (farenheit, humidity)).send()
            else:
                logger.info("Uncaught command from %s: %s" %
                            (from_account, message['body']))
コード例 #30
0
ファイル: noaa.py プロジェクト: rafatahmed/SprinklerSwitch
 def __init__(self):
     lat = configuration.get('latitude')
     lon = configuration.get('longitude')
     self.url = noaa_url % (lat, lon)
コード例 #31
0
ファイル: run_clock.py プロジェクト: DakotaHoosier/hack-clock
#!/usr/bin/python

import time
import datetime
from Libs.Clock import Clock
from Libs.SevenSegment import Display
from Libs.Weather import Weather
from Libs.Input import Button
from Libs.GStreamer import Speaker
from config import configuration

# The weather station
station_name = configuration.get("weather_station")
weather_station = Weather(station_name)

# Connect to the internal machine clock
clock = Clock()

# Connect to the LED display
display = Display()

# Connect to the speaker
speaker = Speaker()

# Play some music
def playMusic():
    speaker.playList(["TestTrack.ogg", "AmicusMeus.ogg"])


# Wake us up at 8:30 in the morning
clock.atTime(8, 30, playMusic)
コード例 #32
0
ファイル: media.py プロジェクト: deckerego/GarageSecurity
 def get_dates(self):
 	archive_dir = configuration.get('webcam_archive')
 	dirpath, dirnames, filenames = next(os.walk(archive_dir))
     archive_dates = filter(lambda f: self.is_valid_date(f), dirnames)
     return sorted(archive_dates, reverse=True)
コード例 #33
0
ファイル: media.py プロジェクト: plasmacorral/GarageSecurity
 def get_dates(self):
     archive_dir = configuration.get('webcam_archive')
     dirpath, dirnames, filenames = next(os.walk(archive_dir))
     archive_dates = filter(lambda f: self.is_valid_date(f), dirnames)
     return sorted(archive_dates, reverse=True)
コード例 #34
0
ファイル: routes.py プロジェクト: rafatahmed/SprinklerSwitch
def dashboard():
	return template('index', webcam_url=configuration.get('webcam_url'))
コード例 #35
0
ファイル: routes.py プロジェクト: deckerego/GarageSecurity
def home():
	return template('index', webcam_url=configuration.get('webcam_url'))
コード例 #36
0
 def _get_code_version(self):
     version = upgrade_config.get('version')
     if not version:
         _logger.warning('Unspecified version in upgrades configuration file')
     _logger.debug('code version: %s', version)
     return version
コード例 #37
0
def dashboard():
    return template('index', webcam_url=configuration.get('webcam_url'))
コード例 #38
0
os.chdir(os.path.dirname(__file__))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),
                                                ".")))

import gpio
import json
import time
import datetime
from HIH6130 import Temperature
from noaa import Forecast
from jabber import Jabber
from config import configuration
from bottle import Bottle, HTTPResponse, static_file, get, put, request, response, template

instance_name = configuration.get('instance_name')

temperature = Temperature()
forecast = Forecast()
jabber_service = Jabber(configuration.get('xmpp_username'),
                        configuration.get('xmpp_password'), temperature)

application = Bottle()
application.install(temperature)
application.install(forecast)
#FIXME Right now two clients (like garagesec and sprinkler) can't co-exist
#application.install(jabber_service)


@application.route('/favicon.ico')
def send_favicon():
コード例 #39
0
ファイル: noaa.py プロジェクト: deckerego/SprinklerSwitch
 def __init__(self):
     lat = configuration.get('latitude')
     lon = configuration.get('longitude')
     self.url = noaa_url % (lat, lon)
コード例 #40
0
ファイル: s3.py プロジェクト: deckerego/GarageSecurity
 def __init__(self):
     self.instance_name = configuration.get('instance_name')
     self.s3conn = S3Connection(configuration.get('aws_key'), configuration.get('aws_secret'))
     self.bucket = self.s3conn.get_bucket(configuration.get('s3_bucket'))
コード例 #41
0
def home():
    return template('index', webcam_url=configuration.get('webcam_url'))
コード例 #42
0
ファイル: routes.py プロジェクト: deckerego/GarageSecurity
os.chdir(os.path.dirname(__file__))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".")))

import json
import time, datetime
import re
from piwiring import GPIO
from jabber import Jabber
from camera import Camera
from HIH6130 import Temperature
from media import Media
from config import configuration
from bottle import Bottle, HTTPResponse, static_file, get, put, request, response, template, redirect

instance_name = configuration.get('instance_name')

camera = Camera()
temperature = Temperature()
gpio = GPIO()
jabber_service = Jabber(configuration.get('xmpp_username'), configuration.get('xmpp_password'), camera, temperature)
media = Media()

application = Bottle()
application.install(temperature)
application.install(gpio)
application.install(jabber_service)
application.install(media)

@application.route('/favicon.ico')
def send_favicon():
コード例 #43
0
ファイル: run_clock.py プロジェクト: DakotaHoosier/hack-clock
#!/usr/bin/python

import time
import datetime
from Libs.Clock import Clock
from Libs.PiTFT import Display
from Libs.Weather import Weather
from Libs.Input import Button
from Libs.GStreamer import Speaker
from config import configuration

# The weather station
station_name = configuration.get('weather_station')
weather_station = Weather(station_name)

# Connect to the internal machine clock
clock = Clock()

# Connect to the LED display
display = Display()

# Connect to the speaker
speaker = Speaker()

# Play some music
def playMusic():
    speaker.playList(["TestTrack.ogg", "AmicusMeus.ogg"])

# Wake us up at 8:30 in the morning
clock.atTime(8, 30, playMusic)
コード例 #44
0
ファイル: routes.py プロジェクト: DakotaHoosier/hack-clock
def audio_list():
	audio_dir = configuration.get('audio_files')
	files = listdir(audio_dir)
	return template('audio', files=files)
コード例 #45
0
ファイル: routes.py プロジェクト: deckerego/GarageSecurity
def get_lastevent(jabber):
	archive_dir = configuration.get('webcam_archive')
	time_struct = max(map(lambda x: os.path.getmtime("%s/%s" % (archive_dir, x)), os.listdir(archive_dir)))
	return '{ "datetime": "%s" }' % time.strftime("%c", time.localtime(time_struct))
コード例 #46
0
ファイル: routes.py プロジェクト: DakotaHoosier/hack-clock
def audio_upload():
	uploaded = request.files.get('upload')
	audio_dir = configuration.get('audio_files')
	uploaded.save(audio_dir)
	redirect("/audio")
コード例 #47
0
ファイル: routes.py プロジェクト: deckerego/GarageSecurity
def show_status():
	archive_dir = configuration.get('webcam_archive')
	archive_dir = configuration.get('webcam_archive')
	time_struct = max(map(lambda x: os.path.getmtime("%s/%s" % (archive_dir, x)), os.listdir(archive_dir)))
	return '{ "last_area_detected": "%s" }' % time.strftime("%c", time.localtime(time_struct))
コード例 #48
0
 def __init__(self):
     self.instance_name = configuration.get('instance_name')
     self.s3conn = S3Connection(configuration.get('aws_key'),
                                configuration.get('aws_secret'))
     self.bucket = self.s3conn.get_bucket(configuration.get('s3_bucket'))