コード例 #1
0
ファイル: logic.py プロジェクト: Yelp/PushmasterApp
def set_request_checkedin(request):
    assert request.state == 'accepted'
    push = request.push
    assert push

    request.state = 'checkedin'

    request.put()
    push.bust_requests_cache()

    util.send_mail(
        to=[push.owner.email(), config.mail_to],
        subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
        body='Changes are checked in.\n' + config.url(push.uri))

    im_fields = dict(

        )
    util.send_im(
        to=request.owner.email(),
        message='Changes for <a href="%(request_uri)s">%(request_subject)s</a> are checked into <a href="%(push_uri)s">%(push_name)s</a>.',
        request_uri=config.url(request.uri),
        request_subject=request.subject,
        push_name=push.name or 'the push',
        push_uri=config.url(push.uri),
        )

    return request
コード例 #2
0
ファイル: logic.py プロジェクト: Yelp/PushmasterApp
def reject_request(request, rejector, reason=None):
    push = request.push

    request.push = None
    request.state = 'rejected'
    if reason:
        request.reject_reason = reason

    request.put()
    query.bust_request_caches()
    if push is not None:
        push.bust_requests_cache()

    util.send_im(
        to=request.owner.email(),
        message='<a href="mailto:%(rejector_email)s">%(rejector_name)s</a> rejected your request <a href="%(request_uri)s">%(request_subject)s</a>: %(reason)s',
        rejector_email=rejector.email(),
        rejector_name=user_info(rejector).full_name,
        request_subject=request.subject,
        request_uri=config.url(request.uri),
        reason=reason,
        )

    util.send_mail(
        to=[request.owner.email(), config.mail_to, config.mail_request],
        subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
        body="""This request was rejected.\n\n%s\n\n%s""" % (reason, config.url(request.uri)),
        )

    return request
コード例 #3
0
ファイル: table.py プロジェクト: backgroundcheck/regenesis
def load_structure(table_id):
    # TODO Return trees, not dict
    setup = {'global': [], 'top': [], 'pre': []}
    vars = []
    ph = urllib2.urlopen(config.url("?sequenz=tabelleAufbau&selectionname=%s&sprache=de" % table_id))
    soup = BeautifulSoup(ph.read())
    ph.close()
    table = soup.find('div', attrs={'class': 'ContentRegion'}).findAll('table')[1]
    for row in table.findAll('tr', recursive=False):
        columns = row.findAll('td', recursive=False)
        if not len(columns):
            continue
        variable = columns[1].contents[0]
        pos = TABLE_SETUP_KEYS.get(columns[0].find('a')['title'])
        
        name_titles = columns[2].findAll('img')
        indent = len([t for t in name_titles if t['title'] == 'Unterordnung'])
        setup[pos] = setup[pos] + [(variable, indent)]
        vars.append(variable)
    return setup, vars
  


                
        
コード例 #4
0
ファイル: logic.py プロジェクト: Yelp/PushmasterApp
def send_request_mail(request):
    body = [request.message or request.subject]
    body.append(config.url(request.uri))

    util.send_mail(
        to=[request.owner.email(), config.mail_to, config.mail_request],
        subject='%s: %s' % (request.owner.nickname(), request.subject),
        body='\n'.join(body))
コード例 #5
0
ファイル: variable.py プロジェクト: backgroundcheck/regenesis
 def _generate():
     for tr in scrape.read_table_pages(config.url("?operation=merkmaleVerzeichnis")):
         td = tr.find('td')
         if not td: continue
         if td.string:
             #print td.string.encode('utf-8')
             yield td.string.encode('utf-8')
         else:
             yield td.find('a').get('id').encode('utf-8')
コード例 #6
0
ファイル: variable.py プロジェクト: pombredanne/regenesis
 def _generate():
     for tr in scrape.read_table_pages(
             config.url("?operation=merkmaleVerzeichnis")):
         td = tr.find('td')
         if not td: continue
         if td.string:
             #print td.string.encode('utf-8')
             yield td.string.encode('utf-8')
         else:
             yield td.find('a').get('id').encode('utf-8')
コード例 #7
0
ファイル: logic.py プロジェクト: Yelp/PushmasterApp
def send_to_stage(push, stage):
    assert push.state in ('accepting', 'onstage')
    assert stage in model.Push.all_stages

    checkedin_requests = query.push_requests(push, state='checkedin')
    if checkedin_requests:
        if push.state != 'onstage' or push.stage != stage:
            push.state = 'onstage'
            push.stage = stage

            push.put()
            query.bust_push_caches()

        for request in checkedin_requests:
            request.state = 'onstage'
            owner_email = request.owner.email()

            util.send_mail(
                to=[owner_email, config.mail_to],
                subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
                body=('Please verify your changes on %s.\n%s' % (push.stage, config.url(push.uri)))
                )

            util.send_im(
                to=owner_email,
                message='<a href="mailto:%(pushmaster_email)s">%(pushmaster_name)s</a> requests that you verify your changes on %(stage)s for <a href="%(push_uri)s">%(request_subject)s</a>.',
                pushmaster_email=push.owner.email(),
                pushmaster_name=user_info(push.owner).full_name,
                request_subject=request.subject,
                push_uri=config.url(push.uri),
                stage=push.stage,
                )
            request.put()

        push.bust_requests_cache()

    return push
コード例 #8
0
ファイル: logic.py プロジェクト: Yelp/PushmasterApp
def accept_request(push, request):
    assert push.state in ('accepting', 'onstage')
    assert request.state == 'requested'
    assert not request.push

    request.push = push
    request.state = 'accepted'

    request.put()
    query.bust_request_caches()
    push.bust_requests_cache()

    util.send_im(
        to=request.owner.email(),
        message='<a href="mailto:%(pushmaster_email)s">%(pushmaster_name)s</a> accepted <a href="%(request_uri)s">%(request_subject)s</a> into <a href="%(push_uri)s">%(push_name)s</a>.',
        pushmaster_email=push.owner.email(),
        pushmaster_name=user_info(push.owner).full_name,
        request_uri=config.url(request.uri),
        request_subject=request.subject,
        push_uri=config.url(push.uri),
        push_name=push.name or 'the push',
        )

    return request
コード例 #9
0
def requestJson(command, params={}):
    url = config.url(command)

    if config.debug:
        print("Invoking: " + url)

    try:
        response = requests.get(url, params=params)
    except requests.exceptions.RequestException as e:
        print("Request failed:")
        print(e)
        sys.exit(1)

    try:
        return response.json()
    except ValueError:
        print("Invalid response:")
        print(response.text)
        sys.exit(1)
コード例 #10
0
ファイル: logic.py プロジェクト: Yelp/PushmasterApp
def withdraw_request(request):
    assert request.state in ('accepted', 'checkedin', 'onstage', 'tested')
    push = request.push
    assert push
    assert request.push.state in ('accepting', 'onstage')

    push_owner_email = request.push.owner.email()
    request.push = None
    request.state = 'requested'

    request.put()
    query.bust_request_caches()
    push.bust_requests_cache()

    util.send_mail(
        to=[push_owner_email, config.mail_to, config.mail_request],
        subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
        body='I withdrew my request.\n' + config.url(request.uri))

    return request
コード例 #11
0
ファイル: logic.py プロジェクト: Yelp/PushmasterApp
def set_request_tested(request, bust_caches=True):
    assert request.state == 'onstage'
    push = request.push
    assert push

    request.state = 'tested'
    request.put()

    if bust_caches:
        push.bust_requests_cache()

    push_owner_email = push.owner.email()

    util.send_mail(
        to=[push_owner_email, config.mail_to],
        subject='Re: %s: %s' % (request.owner.nickname(), request.subject),
        body='Looks good to me.\n' + config.url(push.uri))

    if all(request.state == 'tested' for request in query.push_requests(push)):
        util.send_im(push_owner_email, 'All changes for <a href="%s">the push</a> are verified on stage.' % config.url(push.uri))

    return request
コード例 #12
0
ファイル: table.py プロジェクト: pombredanne/regenesis
def load_structure(table_id):
    # TODO Return trees, not dict
    setup = {'global': [], 'top': [], 'pre': []}
    vars = []
    ph = urllib2.urlopen(
        config.url("?sequenz=tabelleAufbau&selectionname=%s&sprache=de" %
                   table_id))
    soup = BeautifulSoup(ph.read())
    ph.close()
    table = soup.find('div', attrs={
        'class': 'ContentRegion'
    }).findAll('table')[1]
    for row in table.findAll('tr', recursive=False):
        columns = row.findAll('td', recursive=False)
        if not len(columns):
            continue
        variable = columns[1].contents[0]
        pos = TABLE_SETUP_KEYS.get(columns[0].find('a')['title'])

        name_titles = columns[2].findAll('img')
        indent = len([t for t in name_titles if t['title'] == 'Unterordnung'])
        setup[pos] = setup[pos] + [(variable, indent)]
        vars.append(variable)
    return setup, vars
コード例 #13
0
ファイル: statistic.py プロジェクト: pombredanne/regenesis
def load_variables(stat_id):
    url = config.url("?sequenz=statistikMerkmale&selectionname=%s&sprache=de" % stat_id)
    for tr in scrape.read_table_pages(url):
        td = tr.find('td')
        if td:
            yield td.find('div').contents[0]
コード例 #14
0
ファイル: main.py プロジェクト: bsyed3/backup
import os
import os.path
from os import path
import pathlib
import config
import functions
import urllib.request, json 

batchLimit = config.batch() #gets bath limit from config file
apiUrl = config.url() #gets api URL from config file
main_dir = config.mainDirectory() #gets name of main directory
d = 'd' #d for directory
f = 'f' #f for file

dir_path = os.path.join(os.path.dirname(os.path.realpath(__file__)))

jsonData = functions.createJson(apiUrl)

#print(list(jsonData['d'].keys())[1])

functions.createDirectory(main_dir, dir_path)

for i in jsonData[d]:
    new_path = os.path.join(dir_path, main_dir)
    functions.createDirectory(i, new_path)

    for j in jsonData[d][i][d]:
        new_path = os.path.join(dir_path, main_dir, i)
        functions.createDirectory(j, new_path)

        for k in jsonData[d][i][d][j][d]:
コード例 #15
0
ファイル: terms.py プロジェクト: pudo/regenesis
def terms_it():
    for tr in scrape.read_table_pages(config.url("?operation=begriffeVerzeichnis")):
        yield tr.findAll("a")[0].get("id")
コード例 #16
0
# This program takes info from a JSON file on a website, formats it for
# an Arduino, and sends it out the serial port everytime the user presses
# enter. This should later be set to print every 200ms, but is set to user
# input while code is tested.

import time
import serial
import os
import linecache
import json
import urllib2
import math
import telemachus_plugin as tele
import config

url = config.url()

ser = serial.Serial(
    port=config.arduinoSerialPort(),
    #port='COM3',
    #baudrate=115200, # Causes the arduino buffer to fill up
    baudrate=9600, # Seems to be working well
   # parity=serial.PARITY_ODD,
   # stopbits=serial.STOPBITS_TWO,
   # bytesize=serial.SEVENBITS
)

gearStatus = 0
global gearStatus
brakeStatus = 0
global brakeStatus
コード例 #17
0
# This allows you to more conveniently write scripts that can interface with
# Telemachus
#url = 'http://127.0.0.1:8085/telemachus/datalink?alt='
#url = 'http://192.168.1.3:8085/telemachus/datalink?alt='
# This is the URL that Telemachus can be found at.
# Adjust it based on your firewall settings.

import json
import urllib2
import time
import os
import math
import config
import socket

url = config.url()

# set time out to 2 second.
socket.setdefaulttimeout(1)


# Telemachus Definitions
#The readings are for the active vessel unless otherwise noted
def read_angularvelocity():
    fresh_json = json.load(urllib2.urlopen(url + 'v.angularVelocity'))
    result = fresh_json["alt"]
    return result


def read_asl():
    fresh_json = json.load(urllib2.urlopen(url + 'v.altitude'))
コード例 #18
0
ファイル: statistic.py プロジェクト: pombredanne/regenesis
def load_description(stat_id):
    url = config.url("?sequenz=statistikInfo&selectionname=%s&sprache=de" % stat_id)
    soup = BeautifulSoup(urllib2.urlopen(url))
    texte = soup.findAll(attrs={'class': 'langtext'})
    text = u'\n'.join([t.contents[0] if len(t.contents) else '\n' for t in texte])
    return text