commit
stringlengths 40
40
| subject
stringlengths 4
1.73k
| repos
stringlengths 5
127k
| old_file
stringlengths 2
751
| new_file
stringlengths 2
751
| new_contents
stringlengths 1
8.98k
| old_contents
stringlengths 0
6.59k
| license
stringclasses 13
values | lang
stringclasses 23
values |
---|---|---|---|---|---|---|---|---|
a492e805fa51940d746a1d251232bc4f13417165 | fix waftools/man.py to install manpages again. | theeternalsw0rd/xmms2,dreamerc/xmms2,theeternalsw0rd/xmms2,six600110/xmms2,six600110/xmms2,dreamerc/xmms2,xmms2/xmms2-stable,chrippa/xmms2,oneman/xmms2-oneman,krad-radio/xmms2-krad,theefer/xmms2,theefer/xmms2,krad-radio/xmms2-krad,oneman/xmms2-oneman,theefer/xmms2,oneman/xmms2-oneman,six600110/xmms2,oneman/xmms2-oneman,chrippa/xmms2,theefer/xmms2,oneman/xmms2-oneman,oneman/xmms2-oneman,oneman/xmms2-oneman-old,theeternalsw0rd/xmms2,mantaraya36/xmms2-mantaraya36,krad-radio/xmms2-krad,oneman/xmms2-oneman-old,six600110/xmms2,theeternalsw0rd/xmms2,six600110/xmms2,chrippa/xmms2,krad-radio/xmms2-krad,mantaraya36/xmms2-mantaraya36,mantaraya36/xmms2-mantaraya36,xmms2/xmms2-stable,dreamerc/xmms2,dreamerc/xmms2,oneman/xmms2-oneman-old,mantaraya36/xmms2-mantaraya36,chrippa/xmms2,dreamerc/xmms2,xmms2/xmms2-stable,chrippa/xmms2,theefer/xmms2,xmms2/xmms2-stable,chrippa/xmms2,krad-radio/xmms2-krad,oneman/xmms2-oneman,oneman/xmms2-oneman-old,theeternalsw0rd/xmms2,theefer/xmms2,xmms2/xmms2-stable,krad-radio/xmms2-krad,theeternalsw0rd/xmms2,mantaraya36/xmms2-mantaraya36,six600110/xmms2,oneman/xmms2-oneman-old,mantaraya36/xmms2-mantaraya36,theefer/xmms2,mantaraya36/xmms2-mantaraya36,xmms2/xmms2-stable | waftools/man.py | waftools/man.py | import Common, Object, Utils, Node, Params
import sys, os
import gzip
from misc import copyobj
def gzip_func(task):
env = task.m_env
infile = task.m_inputs[0].abspath(env)
outfile = task.m_outputs[0].abspath(env)
input = open(infile, 'r')
output = gzip.GzipFile(outfile, mode='w')
output.write(input.read())
return 0
class manobj(copyobj):
def __init__(self, section=1, type='none'):
copyobj.__init__(self, type)
self.fun = gzip_func
self.files = []
self.section = section
def apply(self):
lst = self.to_list(self.files)
for file in lst:
node = self.path.find_source(file)
if not node: fatal('cannot find input file %s for processing' % file)
target = self.target
if not target or len(lst)>1: target = node.m_name
newnode = self.path.find_build(file+'.gz') #target?
if not newnode:
newnode = Node.Node(file+'.gz', self.path)
self.path.append_build(newnode)
task = self.create_task('copy', self.env, 8)
task.set_inputs(node)
task.set_outputs(newnode)
task.m_env = self.env
task.fun = self.fun
if Params.g_commands['install'] or Params.g_commands['uninstall']:
Common.install_files('MANDIR', 'man' + str(self.section), newnode.abspath(self.env))
def setup(env):
Object.register('man', manobj)
def detect(conf):
return 1
| import Common, Object, Utils, Node, Params
import sys, os
import gzip
from misc import copyobj
def gzip_func(task):
env = task.m_env
infile = task.m_inputs[0].abspath(env)
outfile = task.m_outputs[0].abspath(env)
input = open(infile, 'r')
output = gzip.GzipFile(outfile, mode='w')
output.write(input.read())
return 0
class manobj(copyobj):
def __init__(self, section=1, type='none'):
copyobj.__init__(self, type)
self.fun = gzip_func
self.files = []
self.section = section
def apply(self):
lst = self.to_list(self.source)
for file in lst:
node = self.path.find_source(file)
if not node: fatal('cannot find input file %s for processing' % file)
target = self.target
if not target or len(lst)>1: target = node.m_name
newnode = self.path.find_build(file+'.gz') #target?
if not newnode:
newnode = Node.Node(file+'.gz', self.path)
self.path.append_build(newnode)
task = self.create_task('copy', self.env, 8)
task.set_inputs(node)
task.set_outputs(newnode)
task.m_env = self.env
task.fun = self.fun
if Params.g_commands['install'] or Params.g_commands['uninstall']:
Common.install_files('MANDIR', 'man' + str(self.section), newnode.abspath(self.env))
def setup(env):
Object.register('man', manobj)
def detect(conf):
return 1
| lgpl-2.1 | Python |
735a52b8ad4ebf7b6b8bb47e14667cd9004e624b | add some mappings | gsathya/dsalgo,gsathya/dsalgo | algo/lru.py | algo/lru.py | mapping = {}
class Node:
def __init__(self, val):
self.next = None
self.prev = None
self.value = val
class DoublyLinkedList:
def __init__(self):
self.head = None
def insert(self, val):
node = Node(val)
mapping[val] = node
head = self.head
if self.head == None:
self.head = node
else:
while head.next != None:
head = head.next
head.next = node
node.prev = head
def print_list(self):
head = self.head
while head != None:
print head.value
head = head.next
if __name__ == '__main__':
dll = DoublyLinkedList()
for i in range(10):
dll.insert(i)
| class Node:
def __init__(self, val):
self.next = None
self.prev = None
self.value = val
class DoublyLinkedList:
def __init__(self):
self.head = None
def insert(self, val):
node = Node(val)
head = self.head
if self.head == None:
self.head = node
else:
while head.next != None:
head = head.next
head.next = node
node.prev = head
def print_list(self):
head = self.head
while head != None:
print head.value
head = head.next
if __name__ == '__main__':
dll = DoublyLinkedList()
for i in range(10):
dll.insert(i)
| mit | Python |
6bb58e13b657c1546f4f5d1afa70d48a9187f168 | Update server.py | volodink/itstime4science,volodink/itstime4science,volodink/itstime4science | gprs/server.py | gprs/server.py | from socket import *
from modules import decode_packet
import sys
from modules import params
Parser = params.Parser()
argv = Parser.createParser()
ip_and_port = argv.parse_args(sys.argv[1:])
#host = ip_and_port.ip
#port = int(ip_and_port.port)
host = "0.0.0.0"
port = 5100
addr = (host, port)
print(host,port)
tcp_socket = socket(AF_INET, SOCK_STREAM)
tcp_socket.bind(addr)
tcp_socket.listen(10)
loop = True
while loop:
data = None
print('wait connection...')
conn, addr = tcp_socket.accept()
while loop:
f = open('logs/gprs.log', 'a+')
data = conn.recv(109)
decode_packet.insert(data)
print(data)
if data:
f.write(str(data))
f.close()
else:
f.close()
break
conn.close()
tcp_socket.close()
| from socket import *
from modules import decode_packet
import sys
from modules import params
Parser = params.Parser()
argv = Parser.createParser()
ip_and_port = argv.parse_args(sys.argv[1:])
#host = ip_and_port.ip
#port = int(ip_and_port.port)
host = "0.0.0.0"
port = 5300
addr = (host, port)
print(host,port)
tcp_socket = socket(AF_INET, SOCK_STREAM)
tcp_socket.bind(addr)
tcp_socket.listen(10)
loop = True
while loop:
data = None
print('wait connection...')
conn, addr = tcp_socket.accept()
while loop:
f = open('logs/gprs.log', 'a+')
data = conn.recv(109)
decode_packet.insert(data)
print(data)
if data:
f.write(str(data))
f.close()
else:
f.close()
break
conn.close()
tcp_socket.close()
| mit | Python |
85775847e93b35ac19e09962bc2b10f9be666e33 | Update analysis.py with new finallist.py method | lukasschwab/MathIA | analysis.py | analysis.py | import random
import linecache
from unidecode import unidecode
# Process links into list
finallist = [None] * 5716809
with open('links-simple-sorted.txt', 'r') as src:
for line in src:
[oNode, dNode] = line.split(':')
finallist[int(oNode)] = dNode.rstrip('\n')[1:]
# ACTUALLY: pick a random line in links-sorted, and translate the numbers from there
# Get a random node, and pull that line from the links doc; want this to be an option
oNode = random.randint(1,5706070)
dNode = finallist[oNode]
dNode = dNode.split(' ')
# Translate these into titles and print the result
oname = linecache.getline('titles-sorted.txt',int(oNode))
oname = oname[:-1] # Gets rid of the trailing newline
print '\nORIGIN NODE: ' + oname + '\n'
print 'DESTINATION NODES:'
for thisnum in dNode:
dname = linecache.getline('titles-sorted.txt',int(thisnum))[:-1]
print ' ' + dname
print '\n' | import random
import linecache
from unidecode import unidecode
# ACTUALLY: pick a random line in links-sorted, and translate the numbers from there
# Get a random node, and pull that line from the links doc––want this to be an option
# Pull from links because some titles don't have link lines
lineno = random.randint(1,5706070)
linestr = linecache.getline('links-simple-sorted.txt',lineno)
# Process the string to split the "from" and "to" numbers
[origin, dest] = linestr.split(':')
dest = dest[1:-1] # Gets rid of the first space and trailing newline
dest = dest.split(' ') # Split at spaces
# Translate these into title
oname = lincache.getline('titles-sorted.txt',int(origin))
oname = oname[:-1] # Gets rid of the trailing newline
UNIoname = unidecode(u oname)
for thisnum in dest:
dname = linecache.getline('titles-sorted.txt',int(thisnum))[:-1]
UNIdname = unidecode(linecache.getline('titles-sorted.txt', int(thisnum))[:-1])
# Get some stats bro
linksout = len(dest)
# To get linksin need an adjacency matrix
def assemblematrix():
# Something with links-simple-sorted.txt
# Parse that shit in
def linksin(node):
# Locations of value "1" in the row int(node)
def linksout(node):
# Locations of value "1" in the col int(node)
| mit | Python |
6a3f0ade1d8fe16eeda6d339220b7ef877b402e5 | Add no-break options | KaiyiZhang/Secipt,KaiyiZhang/Secipt,KaiyiZhang/Secipt | LFI.TESTER.py | LFI.TESTER.py | '''
@KaiyiZhang Github
'''
import sys
import urllib2
import getopt
import time
target = ''
depth = 6
file = 'etc/passwd'
html = ''
prefix = ''
url = ''
keyword = 'root'
force = False
def usage():
print "LFI.Tester.py Help:"
print "Usage: LFI.TESTER.py -t [-d] [-f] [-k]"
print " -t,--target The test url"
print " -d,--depth The depth for test (Default is 6)"
print " -f,--file The File include (Default is etc/passwd)"
print " -k,--keyword the keyword for vuln check (Default is root)"
try:
if len(sys.argv) < 2:
usage()
sys.exit()
opts,args = getopt.getopt(sys.argv[1:],"ht:d:f:k:n",["help","target=","depth=","file=","keyword=","no-break"])
for opt, arg in opts:
if opt in("-h","--help"):
usage()
sys.exit()
if opt in("-t","--target"):
target = arg
if not target.startswith('http://', 0, 7):
target = 'http://' + target
if opt in("-d","--depth"):
depth = int(arg)
if depth < 1:
usage()
sys.exit()
if opt in("-f","--file"):
file = arg
if file.startswith('/',0,1):
file =file[1:]
if opt in("-k","--keyword"):
keyword = arg
#print keyword
if opt in("-n","--no-break"):
force = True
except getopt.GetoptError:
usage()
sys.exit(2)
for i in range(0,depth):
prefix += '../'
url = target + prefix + file
print "Testing: ",url
try:
response = urllib2.urlopen(url)
#print response.info()
html = response.read()
#print html
except:
pass
if keyword in html:
print url, " is Vulnerable"
if not force:
break
else:
continue
else:
time.sleep(2)
continue
| '''
@KaiyiZhang Github
'''
import sys
import urllib2
import getopt
import time
target = ''
depth = 6
file = 'etc/passwd'
html = ''
prefix = ''
url = ''
keyword='root'
def usage():
print "LFI.Tester.py Help:"
print "Usage: LFI.TESTER.py -t [-d] [-f] [-k]"
print " -t,--target The test url"
print " -d,--depth The depth for test (Default is 6)"
print " -f,--file The File include (Default is etc/passwd)"
print " -k,--keyword the keyword for vuln check (Default is root)"
try:
if len(sys.argv) < 2:
usage()
sys.exit()
opts,args = getopt.getopt(sys.argv[1:],"ht:d:f:k:",["help","target=","depth=","file=","keyword="])
for opt, arg in opts:
if opt in("-h","--help"):
usage()
sys.exit()
if opt in("-t","--target"):
target = arg
if not target.startswith('http://', 0, 7):
target = 'http://' + target
if opt in("-d","--depth"):
depth = int(arg)
if depth < 1:
usage()
sys.exit()
if opt in("-f","--file"):
file = arg
if file.startswith('/',0,1):
file =file[1:]
if opt in("-k","--keyword"):
keyword = arg
#print keyword
except getopt.GetoptError:
usage()
sys.exit(2)
for i in range(0,depth):
prefix += '../'
url = target + prefix + file
print "Testing: ",url
try:
response = urllib2.urlopen(url)
#print response.info()
html = response.read()
#print html
except:
pass
if(keyword in html):
print url, " is Vulnerable"
break
else:
time.sleep(2)
continue
| apache-2.0 | Python |
68c0c054e5b9874f8a6423c35fb83c9de351b9e0 | fix doc build | jbogaardt/chainladder-python,jbogaardt/chainladder-python | examples/plot_benktander.py | examples/plot_benktander.py | """
====================================================================
Benktander: Relationship between Chainladder and BornhuetterFerguson
====================================================================
This example demonstrates the relationship between the Chainladder and
BornhuetterFerguson methods by way fo the Benktander model. Each is a
special case of the Benktander model where ``n_iters = 1`` for BornhuetterFerguson
and as ``n_iters`` approaches infinity yields the chainladder. As ``n_iters``
increases the apriori selection becomes less relevant regardless of initial
choice.
"""
import chainladder as cl
# Load Data
clrd = cl.load_sample('clrd')
medmal_paid = clrd.groupby('LOB').sum().loc['medmal', 'CumPaidLoss']
medmal_prem = clrd.groupby('LOB').sum().loc['medmal', 'EarnedPremDIR'].latest_diagonal
# Generate LDFs and Tail Factor
medmal_paid = cl.Development().fit_transform(medmal_paid)
medmal_paid = cl.TailCurve().fit_transform(medmal_paid)
# Benktander Model
benk = cl.Benktander()
# Prep Benktander Grid Search with various assumptions, and a scoring function
param_grid = dict(n_iters=list(range(1,100,2)),
apriori=[0.50, 0.75, 1.00])
scoring = {'IBNR':lambda x: x.ibnr_.sum()}
grid = cl.GridSearch(benk, param_grid, scoring=scoring)
# Perform Grid Search
grid.fit(medmal_paid, sample_weight=medmal_prem)
# Plot data
grid.results_.pivot(index='n_iters', columns='apriori', values='IBNR').plot(
title='Benktander convergence to Chainladder', grid=True).set(ylabel='IBNR')
| """
====================================================================
Benktander: Relationship between Chainladder and BornhuetterFerguson
====================================================================
This example demonstrates the relationship between the Chainladder and
BornhuetterFerguson methods by way fo the Benktander model. Each is a
special case of the Benktander model where ``n_iters = 1`` for BornhuetterFerguson
and as ``n_iters`` approaches infinity yields the chainladder. As ``n_iters``
increases the apriori selection becomes less relevant regardless of initial
choice.
"""
import chainladder as cl
# Load Data
clrd = cl.load_sample('clrd')
medmal_paid = clrd.groupby('LOB').sum().loc['medmal', 'CumPaidLoss']
medmal_prem = clrd.groupby('LOB').sum().loc['medmal', 'EarnedPremDIR'].latest_diagonal
medmal_prem.rename('development', ['premium'])
# Generate LDFs and Tail Factor
medmal_paid = cl.Development().fit_transform(medmal_paid)
medmal_paid = cl.TailCurve().fit_transform(medmal_paid)
# Benktander Model
benk = cl.Benktander()
# Prep Benktander Grid Search with various assumptions, and a scoring function
param_grid = dict(n_iters=list(range(1,100,2)),
apriori=[0.50, 0.75, 1.00])
scoring = {'IBNR':lambda x: x.ibnr_.sum()}
grid = cl.GridSearch(benk, param_grid, scoring=scoring)
# Perform Grid Search
grid.fit(medmal_paid, sample_weight=medmal_prem)
# Plot data
grid.results_.pivot(index='n_iters', columns='apriori', values='IBNR').plot(
title='Benktander convergence to Chainladder', grid=True).set(ylabel='IBNR')
| mit | Python |
15307ebe2c19c1a3983b0894152ba81fdde34619 | Add comment on dist of first function | charanpald/tyre-hug | exp/descriptivestats.py | exp/descriptivestats.py | import pandas
import numpy
import matplotlib.pyplot as plt
def univariate_stats():
# Generate 1000 random numbers from a normal distribution
num_examples = 1000
z = pandas.Series(numpy.random.randn(num_examples))
# Minimum
print(z.min())
# Maximum
print(z.max())
# Mean
print(z.mean())
# Median
print(z.median())
# Variance
print(z.var())
# Standard deviation
print(z.std())
# Mean absolute deviation
print(z.mad())
# Interquartile range
print(z.quantile(0.75) - z.quantile(0.25))
z.plot(kind="hist")
def multivariate_stats():
num_examples = 1000
x = pandas.Series(numpy.random.randn(num_examples))
y = x + pandas.Series(numpy.random.randn(num_examples))
z = x + pandas.Series(numpy.random.randn(num_examples))
# Covariance
print(y.cov(z))
# Covariance of y with itself is equal to variance
print(y.cov(y), y.var())
# Correlation
print(y.corr(z))
univariate_stats()
multivariate_stats()
plt.show()
| import pandas
import numpy
import matplotlib.pyplot as plt
def univariate_stats():
num_examples = 1000
z = pandas.Series(numpy.random.randn(num_examples))
# Minimum
print(z.min())
# Maximum
print(z.max())
# Mean
print(z.mean())
# Median
print(z.median())
# Variance
print(z.var())
# Standard deviation
print(z.std())
# Mean absolute deviation
print(z.mad())
# Interquartile range
print(z.quantile(0.75) - z.quantile(0.25))
z.plot(kind="hist")
def multivariate_stats():
num_examples = 1000
x = pandas.Series(numpy.random.randn(num_examples))
y = x + pandas.Series(numpy.random.randn(num_examples))
z = x + pandas.Series(numpy.random.randn(num_examples))
# Covariance
print(y.cov(z))
# Covariance of y with itself is equal to variance
print(y.cov(y), y.var())
# Correlation
print(y.corr(z))
univariate_stats()
multivariate_stats()
plt.show()
| mit | Python |
9af7c8bfc22a250ce848d50ca26877e177f767c1 | Fix execution on Monday | flopezag/fiware-management-scripts,flopezag/fiware-management-scripts | management.py | management.py | from logging import _nameToLevel as nameToLevel
from argparse import ArgumentParser
from Common.emailer import Emailer
from DesksReminder.reminders import HelpDeskTechReminder, HelpDeskLabReminder, HelpDeskOtherReminder, \
UrgentDeskReminder, AccountsDeskReminder
from HelpDesk.synchronization import AskbotSync, HelpDeskCaretaker
from HelpDesk.stackoverflowsync import StackOverflowSync
from urllib3 import disable_warnings
from urllib3.exceptions import InsecureRequestWarning
from datetime import datetime
__author__ = 'Fernando López'
__version__ = "1.3.0"
def init():
parser = ArgumentParser(prog='Jira Management Scripts', description='')
parser.add_argument('-l',
'--log',
default='INFO',
help='The logging level to be used.')
args = parser.parse_args()
loglevel = None
try:
loglevel = nameToLevel[args.log.upper()]
except Exception as e:
print('Invalid log level: {}'.format(args.log))
print('Please use one of the following values:')
print(' * CRITICAL')
print(' * ERROR')
print(' * WARNING')
print(' * INFO')
print(' * DEBUG')
print(' * NOTSET')
exit()
return loglevel
if __name__ == "__main__":
loglevel = init()
mailer = Emailer(loglevel=loglevel)
disable_warnings(InsecureRequestWarning)
today = datetime.today().weekday()
if today == 0:
# Send reminder of pending JIRA tickets, only every Mondays
techReminder = HelpDeskTechReminder(loglevel=loglevel, mailer=mailer)
techReminder.process()
labReminder = HelpDeskLabReminder(loglevel=loglevel, mailer=mailer)
labReminder.process()
otherReminder = HelpDeskOtherReminder(loglevel=loglevel, mailer=mailer)
otherReminder.process()
urgentReminder = UrgentDeskReminder(loglevel=loglevel, mailer=mailer)
urgentReminder.process()
accountReminder = AccountsDeskReminder(loglevel=loglevel, mailer=mailer)
accountReminder.process()
# Askbot synchronization and Jira caretaker actions, every day
askbotSync = AskbotSync(loglevel=loglevel)
askbotSync.process()
# Automatic reassign tickets to owners based on some extracted information, every day
helpdeskCaretaker = HelpDeskCaretaker(loglevel=loglevel)
helpdeskCaretaker.process()
# StackoverFlow synchronization, every day
stackoverflowSync = StackOverflowSync(loglevel=loglevel)
stackoverflowSync.process(year=2015, month=9, day=21)
| from logging import _nameToLevel as nameToLevel
from argparse import ArgumentParser
from Common.emailer import Emailer
from DesksReminder.reminders import HelpDeskTechReminder, HelpDeskLabReminder, HelpDeskOtherReminder, \
UrgentDeskReminder, AccountsDeskReminder
from HelpDesk.synchronization import AskbotSync, HelpDeskCaretaker
from HelpDesk.stackoverflowsync import StackOverflowSync
from urllib3 import disable_warnings
from urllib3.exceptions import InsecureRequestWarning
from datetime import datetime
__author__ = 'Fernando López'
__version__ = "1.3.0"
def init():
parser = ArgumentParser(prog='Jira Management Scripts', description='')
parser.add_argument('-l',
'--log',
default='INFO',
help='The logging level to be used.')
args = parser.parse_args()
loglevel = None
try:
loglevel = nameToLevel[args.log.upper()]
except Exception as e:
print('Invalid log level: {}'.format(args.log))
print('Please use one of the following values:')
print(' * CRITICAL')
print(' * ERROR')
print(' * WARNING')
print(' * INFO')
print(' * DEBUG')
print(' * NOTSET')
exit()
return loglevel
if __name__ == "__main__":
loglevel = init()
mailer = Emailer(loglevel=loglevel)
disable_warnings(InsecureRequestWarning)
today = datetime.today().weekday()
if today == 2:
# Send reminder of pending JIRA tickets, only every Mondays
techReminder = HelpDeskTechReminder(loglevel=loglevel, mailer=mailer)
techReminder.process()
labReminder = HelpDeskLabReminder(loglevel=loglevel, mailer=mailer)
labReminder.process()
otherReminder = HelpDeskOtherReminder(loglevel=loglevel, mailer=mailer)
otherReminder.process()
urgentReminder = UrgentDeskReminder(loglevel=loglevel, mailer=mailer)
urgentReminder.process()
accountReminder = AccountsDeskReminder(loglevel=loglevel, mailer=mailer)
accountReminder.process()
# Askbot synchronization and Jira caretaker actions, every day
askbotSync = AskbotSync(loglevel=loglevel)
askbotSync.process()
# Automatic reassign tickets to owners based on some extracted information, every day
helpdeskCaretaker = HelpDeskCaretaker(loglevel=loglevel)
helpdeskCaretaker.process()
# StackoverFlow synchronization, every day
stackoverflowSync = StackOverflowSync(loglevel=loglevel)
stackoverflowSync.process(year=2015, month=9, day=21)
| apache-2.0 | Python |
ecd2821a99dee895f3ab7c5dbcc6d86983268560 | Update src url for dev in views | patrickbeeson/text-me | __init__.py | __init__.py | from flask import Flask, request, redirect, url_for
from twilio.rest import TwilioRestClient
from PIL import Image, ImageDraw, ImageFont
import time
app = Flask(__name__, static_folder='static', static_url_path='')
client = TwilioRestClient(
account='ACb01b4d6edfb1b41a8b80f5fed2c19d1a',
token='97e6b9c0074b2761eff1375fb088adda'
)
@app.route('/', methods=['GET', 'POST'])
def send_image():
if request.method == 'GET':
return 'The deployment worked! Now copy your browser URL into the' + \
' Twilio message text box for your phone number.'
sender_number = request.form.get('From', '')
twilio_number = request.form.get('To', '')
user_text = request.form.get('Body', '')
image_url, msg_text = mod_photo(user_text)
send_mms_twiml(image_url, msg_text, sender_number, twilio_number)
return 'ok'
def mod_photo(user_text):
base = Image.open('static/images/original/portland.jpg').convert('RGBA')
txt = Image.new('RGBA', base.size, (255, 255, 255, 0))
fnt = ImageFont.truetype('static/fonts/Gobold.ttf', 30)
d = ImageDraw.Draw(txt)
d.text(
(25, 25),
'{}...'.format(user_text),
font=fnt,
fill=(255, 255, 255, 255)
)
image = Image.alpha_composite(base, txt)
image.save('static/images/changed/portland_{}.jpg'.format(user_text))
try:
msg_text = '{}: Imagine yourself in Portland!'.format(user_text)
image_url = 'http://dev.thevariable.com/images/changed/portland_{}.jpg'.format(user_text)
except:
msg = "Sorry, we couldn't pull a kitten, " + \
"here's a dinosaur instead!"
image_url = "https://farm1.staticflickr.com/46/" + \
"154877897_a299d80baa_b_d.jpg"
return image_url, msg_text
def send_mms_twiml(image_url, msg_text, sender_number, twilio_number):
client.messages.create(
to=sender_number,
from_=twilio_number,
body=msg_text,
media_url=image_url
)
if __name__ == "__main__":
app.run(debug=True)
| from flask import Flask, request, redirect, url_for
from twilio.rest import TwilioRestClient
from PIL import Image, ImageDraw, ImageFont
import time
app = Flask(__name__, static_folder='static', static_url_path='')
client = TwilioRestClient(
account='ACb01b4d6edfb1b41a8b80f5fed2c19d1a',
token='97e6b9c0074b2761eff1375fb088adda'
)
@app.route('/', methods=['GET', 'POST'])
def send_image():
if request.method == 'GET':
return 'The deployment worked! Now copy your browser URL into the' + \
' Twilio message text box for your phone number.'
sender_number = request.form.get('From', '')
twilio_number = request.form.get('To', '')
user_text = request.form.get('Body', '')
image_url, msg_text = mod_photo(user_text)
send_mms_twiml(image_url, msg_text, sender_number, twilio_number)
return 'ok'
def mod_photo(user_text):
base = Image.open('static/images/original/portland.jpg').convert('RGBA')
txt = Image.new('RGBA', base.size, (255, 255, 255, 0))
fnt = ImageFont.truetype('static/fonts/Gobold.ttf', 30)
d = ImageDraw.Draw(txt)
d.text(
(25, 25),
'{}...'.format(user_text),
font=fnt,
fill=(255, 255, 255, 255)
)
image = Image.alpha_composite(base, txt)
image.save('static/images/changed/portland_{}.jpg'.format(user_text))
try:
msg_text = '{}: Imagine yourself in Portland!'.format(user_text)
image_url = 'http://12dcb913.ngrok.com/images/changed/portland_{}.jpg'.format(user_text)
except:
msg = "Sorry, we couldn't pull a kitten, " + \
"here's a dinosaur instead!"
image_url = "https://farm1.staticflickr.com/46/" + \
"154877897_a299d80baa_b_d.jpg"
return image_url, msg_text
def send_mms_twiml(image_url, msg_text, sender_number, twilio_number):
client.messages.create(
to=sender_number,
from_=twilio_number,
body=msg_text,
media_url=image_url
)
if __name__ == "__main__":
app.run(debug=True)
| mit | Python |
598bb39414825ff8ab561babb470b85f06c58020 | Update __init__.py | scipsycho/mlpack | __init__.py | __init__.py | from mlpack.linear_regression import linear_regression
from mlpack.logistic_regression import logistic_regression
"""
MlPack
======
Provides
1. A Variety of Machine learning packages
2. Good and Easy hand written programs with good documentation
3. Linear Regression, Logistic Regression
Available subpackages
---------------------
1. Linear Regression
2. Logistic Regression
See subpackages for more details.
"""
| from mlpack import linear_regression
from mlpack import logistic_regression
"""
MlPack
======
Provides
1. A Variety of Machine learning packages
2. Good and Easy hand written programs with good documentation
3. Linear Regression, Logistic Regression
Available subpackages
---------------------
1. Linear Regression
2. Logistic Regression
See subpackages for more details.
"""
| mit | Python |
b8d0344f0ca5c906e43d4071bc27a8d2acf114d1 | bump version | wistful/webmpris | webmpris/__init__.py | webmpris/__init__.py | __version__ = '1.1'
__description__ = 'REST API to control media players via MPRIS2 interfaces'
requires = [
'pympris'
]
README = """webmpris is a REST API
to control media players via MPRIS2 interfaces.
Supported intefaces:
org.mpris.MediaPlayer2 via /players/<id>/Root
org.mpris.MediaPlayer2.Player via /players/<id>/Player
org.mpris.MediaPlayer2.TrackList via /players/<id>/TrackList
org.mpris.MediaPlayer2.Playlists via /players/<id>/Playlists
"""
| __version__ = '1.0'
__description__ = 'REST API to control media players via MPRIS2 interfaces'
requires = [
'pympris'
]
README = """webmpris is a REST API
to control media players via MPRIS2 interfaces.
Supported intefaces:
org.mpris.MediaPlayer2 via /players/<id>/Root
org.mpris.MediaPlayer2.Player via /players/<id>/Player
org.mpris.MediaPlayer2.TrackList via /players/<id>/TrackList
org.mpris.MediaPlayer2.Playlists via /players/<id>/Playlists
"""
| mit | Python |
9acf7857167bb87438c7c0bebca1a7eda93ac23b | Make saml2idp compatible with Django 1.9 | mobify/dj-saml-idp,mobify/dj-saml-idp,mobify/dj-saml-idp | saml2idp/registry.py | saml2idp/registry.py | # -*- coding: utf-8 -*-
from __future__ import absolute_import
"""
Registers and loads Processor classes from settings.
"""
import logging
from importlib import import_module
from django.core.exceptions import ImproperlyConfigured
from . import exceptions
from . import saml2idp_metadata
logger = logging.getLogger(__name__)
def get_processor(config):
"""
Get an instance of the processor with config.
"""
dottedpath = config['processor']
try:
dot = dottedpath.rindex('.')
except ValueError:
raise ImproperlyConfigured('%s isn\'t a processors module' % dottedpath)
sp_module, sp_classname = dottedpath[:dot], dottedpath[dot+1:]
try:
mod = import_module(sp_module)
except ImportError, e:
raise ImproperlyConfigured('Error importing processors %s: "%s"' % (sp_module, e))
try:
sp_class = getattr(mod, sp_classname)
except AttributeError:
raise ImproperlyConfigured('processors module "%s" does not define a "%s" class' % (sp_module, sp_classname))
instance = sp_class(config)
return instance
def find_processor(request):
"""
Returns the Processor instance that is willing to handle this request.
"""
for name, sp_config in saml2idp_metadata.SAML2IDP_REMOTES.items():
proc = get_processor(sp_config)
try:
if proc.can_handle(request):
return proc
except exceptions.CannotHandleAssertion as exc:
# Log these, but keep looking.
logger.debug('%s %s' % (proc, exc))
raise exceptions.CannotHandleAssertion('None of the processors in SAML2IDP_REMOTES could handle this request.')
| # -*- coding: utf-8 -*-
from __future__ import absolute_import
"""
Registers and loads Processor classes from settings.
"""
# Python imports
import logging
# Django imports
from django.utils.importlib import import_module
from django.core.exceptions import ImproperlyConfigured
# Local imports
from . import exceptions
from . import saml2idp_metadata
# Setup logging
logger = logging.getLogger(__name__)
def get_processor(config):
"""
Get an instance of the processor with config.
"""
dottedpath = config['processor']
try:
dot = dottedpath.rindex('.')
except ValueError:
raise ImproperlyConfigured('%s isn\'t a processors module' % dottedpath)
sp_module, sp_classname = dottedpath[:dot], dottedpath[dot+1:]
try:
mod = import_module(sp_module)
except ImportError, e:
raise ImproperlyConfigured('Error importing processors %s: "%s"' % (sp_module, e))
try:
sp_class = getattr(mod, sp_classname)
except AttributeError:
raise ImproperlyConfigured('processors module "%s" does not define a "%s" class' % (sp_module, sp_classname))
instance = sp_class(config)
return instance
def find_processor(request):
"""
Returns the Processor instance that is willing to handle this request.
"""
for name, sp_config in saml2idp_metadata.SAML2IDP_REMOTES.items():
proc = get_processor(sp_config)
try:
if proc.can_handle(request):
return proc
except exceptions.CannotHandleAssertion as exc:
# Log these, but keep looking.
logger.debug('%s %s' % (proc, exc))
raise exceptions.CannotHandleAssertion('None of the processors in SAML2IDP_REMOTES could handle this request.')
| mit | Python |
b8cd1b6869651cd0cbe2cbeebc59c641f13e0e5b | Add todo for scopes permissions | polyaxon/polyaxon,polyaxon/polyaxon,polyaxon/polyaxon | polyaxon/scopes/permissions/scopes.py | polyaxon/scopes/permissions/scopes.py | from scopes.authentication.ephemeral import is_ephemeral_user
from scopes.authentication.internal import is_internal_user
from scopes.permissions.base import PolyaxonPermission
class ScopesPermission(PolyaxonPermission):
"""
Scopes based Permissions, depends on the authentication backend.
"""
ENTITY = None
SCOPE_MAPPING = None
@staticmethod
def _check_internal_or_ephemeral(request):
return any([is_ephemeral_user(request.user), is_internal_user(request.user)])
def has_permission(self, request, view):
if not request.auth:
if not request.user.is_authenticated:
return False
# Session users are granted total access
return True
# TODO Add internal/ephemeral here
# (if that type of auth is allowed, then we should not check he scope)
if request.user.is_authenticated and request.user.is_superuser:
return True
allowed_scopes = set(self.SCOPE_MAPPING.get(request.method, []))
if not allowed_scopes:
return True
current_scopes = request.auth.scopes
return any(s in allowed_scopes for s in current_scopes)
| from scopes.authentication.ephemeral import is_ephemeral_user
from scopes.authentication.internal import is_internal_user
from scopes.permissions.base import PolyaxonPermission
class ScopesPermission(PolyaxonPermission):
"""
Scopes based Permissions, depends on the authentication backend.
"""
ENTITY = None
SCOPE_MAPPING = None
@staticmethod
def _check_internal_or_ephemeral(request):
return any([is_ephemeral_user(request.user), is_internal_user(request.user)])
def has_permission(self, request, view):
if not request.auth:
if not request.user.is_authenticated:
return False
# Session users are granted total access
return True
if request.user.is_authenticated and request.user.is_superuser:
return True
allowed_scopes = set(self.SCOPE_MAPPING.get(request.method, []))
if not allowed_scopes:
return True
current_scopes = request.auth.scopes
return any(s in allowed_scopes for s in current_scopes)
| apache-2.0 | Python |
c202a3a945453a4955f0acbf369227f8c9cee148 | Rename link in init | analysiscenter/dataset | __init__.py | __init__.py | import os
from .batchflow import *
__path__ = [os.path.join(os.path.dirname(__file__), 'batchflow')]
| import os
from .dataset import *
__path__ = [os.path.join(os.path.dirname(__file__), 'dataset')]
| apache-2.0 | Python |
4a4731eda22170a77bb24dd3c7fc8ff4cafecf9d | bump version to 2.7b1 | pypa/setuptools,pypa/setuptools,pypa/setuptools | __init__.py | __init__.py | """distutils
The main package for the Python Module Distribution Utilities. Normally
used from a setup script as
from distutils.core import setup
setup (...)
"""
__revision__ = "$Id$"
# Distutils version
#
# Updated automatically by the Python release process.
#
#--start constants--
__version__ = "2.7b1"
#--end constants--
| """distutils
The main package for the Python Module Distribution Utilities. Normally
used from a setup script as
from distutils.core import setup
setup (...)
"""
__revision__ = "$Id$"
# Distutils version
#
# Updated automatically by the Python release process.
#
#--start constants--
__version__ = "2.7a4"
#--end constants--
| mit | Python |
86eb16da4a6c3579eb514fa5ca73def7be8afd84 | Add noqa codestyle | GeotrekCE/Geotrek-admin,GeotrekCE/Geotrek-admin,GeotrekCE/Geotrek-admin,makinacorpus/Geotrek,GeotrekCE/Geotrek-admin,makinacorpus/Geotrek,makinacorpus/Geotrek,makinacorpus/Geotrek | geotrek/api/v2/views/__init__.py | geotrek/api/v2/views/__init__.py | from rest_framework import response, permissions
from rest_framework.views import APIView
from django.conf import settings
from django.contrib.gis.geos import Polygon
from .authent import StructureViewSet # noqa
from .common import TargetPortalViewSet, ThemeViewSet, SourceViewSet, ReservationSystemViewSet, LabelViewSet, OrganismViewSet # noqa
if 'geotrek.core' in settings.INSTALLED_APPS:
from .core import PathViewSet # noqa
if 'geotrek.feedback' in settings.INSTALLED_APPS:
from .feedback import ReportStatusViewSet, ReportActivityViewSet, ReportCategoryViewSet, ReportProblemMagnitudeViewSet # noqa
if 'geotrek.trekking' in settings.INSTALLED_APPS:
from .trekking import (TrekViewSet, TourViewSet, POIViewSet, POITypeViewSet, AccessibilityViewSet, RouteViewSet, # noqa
DifficultyViewSet, NetworkViewSet, PracticeViewSet, # noqa
WebLinkCategoryViewSet, ServiceTypeViewSet, ServiceViewSet, TrekRatingScaleViewSet, TrekRatingViewSet) # noqa
if 'geotrek.sensitivity' in settings.INSTALLED_APPS:
from .sensitivity import SensitiveAreaViewSet # noqa
from .sensitivity import SportPracticeViewSet # noqa
from .sensitivity import SpeciesViewSet # noqa
if 'geotrek.tourism' in settings.INSTALLED_APPS:
from .tourism import TouristicContentViewSet, TouristicEventViewSet, TouristicEventTypeViewSet, InformationDeskViewSet, TouristicContentCategoryViewSet # noqa
if 'geotrek.zoning' in settings.INSTALLED_APPS:
from .zoning import CityViewSet, DistrictViewSet # noqa
if 'geotrek.outdoor' in settings.INSTALLED_APPS:
from .outdoor import (SiteViewSet, OutdoorPracticeViewSet, SiteTypeViewSet, CourseTypeViewSet, # noqa
OutdoorRatingScaleViewSet, OutdoorRatingViewSet, CourseViewSet, SectorViewSet) # noqa
if 'geotrek.flatpages' in settings.INSTALLED_APPS:
from .flatpages import FlatPageViewSet # noqa
if 'geotrek.infrastructure' in settings.INSTALLED_APPS:
from .infrastructure import InfrastructureTypeViewSet, InfrastructureViewSet, InfrastructureUsageDifficultyLevelViewSet, InfrastructureConditionViewSet, InfrastructureMaintenanceDifficultyLevelViewSet # noqa
if 'geotrek.signage' in settings.INSTALLED_APPS:
from .signage import SignageViewSet, SignageTypeViewSet, SealingViewSet, ColorViewSet, DirectionViewSet, BladeTypeViewSet # noqa
if 'drf_yasg' in settings.INSTALLED_APPS:
from .swagger import schema_view # noqa
class ConfigView(APIView):
"""
Configuration endpoint that gives the BBox used in the Geotrek configuration
"""
permission_classes = [permissions.AllowAny, ]
def get(self, request, *args, **kwargs):
bbox = Polygon.from_bbox(settings.SPATIAL_EXTENT)
bbox.srid = settings.SRID
bbox.transform(settings.API_SRID)
return response.Response({
'bbox': bbox.extent
})
| from rest_framework import response, permissions
from rest_framework.views import APIView
from django.conf import settings
from django.contrib.gis.geos import Polygon
from .authent import StructureViewSet # noqa
from .common import TargetPortalViewSet, ThemeViewSet, SourceViewSet, ReservationSystemViewSet, LabelViewSet, OrganismViewSet # noqa
if 'geotrek.core' in settings.INSTALLED_APPS:
from .core import PathViewSet # noqa
if 'geotrek.feedback' in settings.INSTALLED_APPS:
from .feedback import ReportStatusViewSet, ReportActivityViewSet, ReportCategoryViewSet, ReportProblemMagnitudeViewSet # noqa
if 'geotrek.trekking' in settings.INSTALLED_APPS:
from .trekking import (TrekViewSet, TourViewSet, POIViewSet, POITypeViewSet, AccessibilityViewSet, RouteViewSet,
DifficultyViewSet, NetworkViewSet, PracticeViewSet,
WebLinkCategoryViewSet, ServiceTypeViewSet, ServiceViewSet, TrekRatingScaleViewSet, TrekRatingViewSet) # noqa
if 'geotrek.sensitivity' in settings.INSTALLED_APPS:
from .sensitivity import SensitiveAreaViewSet # noqa
from .sensitivity import SportPracticeViewSet # noqa
from .sensitivity import SpeciesViewSet # noqa
if 'geotrek.tourism' in settings.INSTALLED_APPS:
from .tourism import TouristicContentViewSet, TouristicEventViewSet, TouristicEventTypeViewSet, InformationDeskViewSet, TouristicContentCategoryViewSet # noqa
if 'geotrek.zoning' in settings.INSTALLED_APPS:
from .zoning import CityViewSet, DistrictViewSet # noqa
if 'geotrek.outdoor' in settings.INSTALLED_APPS:
from .outdoor import (SiteViewSet, OutdoorPracticeViewSet, SiteTypeViewSet, CourseTypeViewSet,
OutdoorRatingScaleViewSet, OutdoorRatingViewSet, CourseViewSet, SectorViewSet) # noqa
if 'geotrek.flatpages' in settings.INSTALLED_APPS:
from .flatpages import FlatPageViewSet # noqa
if 'geotrek.infrastructure' in settings.INSTALLED_APPS:
from .infrastructure import InfrastructureTypeViewSet, InfrastructureViewSet, InfrastructureUsageDifficultyLevelViewSet, InfrastructureConditionViewSet, InfrastructureMaintenanceDifficultyLevelViewSet # noqa
if 'geotrek.signage' in settings.INSTALLED_APPS:
from .signage import SignageViewSet, SignageTypeViewSet, SealingViewSet, ColorViewSet, DirectionViewSet, BladeTypeViewSet # noqa
if 'drf_yasg' in settings.INSTALLED_APPS:
from .swagger import schema_view # noqa
class ConfigView(APIView):
"""
Configuration endpoint that gives the BBox used in the Geotrek configuration
"""
permission_classes = [permissions.AllowAny, ]
def get(self, request, *args, **kwargs):
bbox = Polygon.from_bbox(settings.SPATIAL_EXTENT)
bbox.srid = settings.SRID
bbox.transform(settings.API_SRID)
return response.Response({
'bbox': bbox.extent
})
| bsd-2-clause | Python |
f9a1da6e60bfbd9c9e5be769f1223d628cec6481 | set the module version | brain-tec/connector,acsone/connector,hugosantosred/connector,brain-tec/connector,anybox/connector,Endika/connector,sylvain-garancher/connector,gurneyalex/connector,maljac/connector,maljac/connector,mohamedhagag/connector,esousy/connector,MindAndGo/connector,open-synergy/connector,acsone/connector,dvitme/connector,MindAndGo/connector,Antiun/connector,BT-ojossen/connector,fevxie/connector,js-landoo/connector,zhaohuaw/connector,BT-jmichaud/connector,fevxie/connector,mohamedhagag/connector,sylvain-garancher/connector,hugosantosred/connector,guewen/connector,Endika/connector,open-synergy/connector,BT-fgarbely/connector,js-landoo/connector,anybox/connector,acsone/connector,brain-tec/connector,BT-jmichaud/connector,esousy/connector,Antiun/connector,zhaohuaw/connector,guewen/connector,gurneyalex/connector,dvitme/connector,BT-ojossen/connector,BT-fgarbely/connector | base_external_referentials/__openerp__.py | base_external_referentials/__openerp__.py | # -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2009 Akretion (<http://www.akretion.com>). All Rights Reserved
# authors: Raphaël Valyi, Sharoon Thomas
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Base External Referentials',
'version': '6.1.0',
'category': 'Generic Modules/Base',
'description': """
Definition : a referential is an external system that will interacts with OpenERP
Goal : store external system connection details and objects fields mapping
This module provide an abstract common minimal base to add any additional external id columns
to some OpenObject table, pointing to some external referential.
A referential is abstract and minimal at this stage, it only has:
* a name
* a location (possibly webservice URL, database connection URL...); the connection method will tell it...
* referential credentials (user name + password)
* placeholders for custom in and out mapping for OpenERP object fields.
OpenERP already has limited supported to external ids using the ir_model_data and the id
fields in the loaded data such as XML or CSV. We think that's OK to store all referential ids
into the same ir_model_data table: yes it makes it large, but synchronisation operations involve
a network bottleneck anyway, so it's largely OK and negligible to have a large table here.
The existing ir_model_data feature of OpenERP is mostly thought as an mono-external referential
(even if the module key of ir_model_data plays some referential scoping role). Here we just push
the concept further to assume multiple external ids for OpenERP entities and add the possibility
to customize their field mapping directly in OpenERP to accomodate the external systems.
""",
'author': 'Raphaël Valyi (Akretion.com), Sharoon Thomas (Openlabs.co.in)',
'website': 'http://www.akretion.com, http://openlabs.co.in/',
'depends': ['base','base_pop_up', 'base_file_protocole', 'email_template'],
'init_xml': [],
'update_xml': [
'external_referentials_view.xml',
'report_view.xml',
'external_referentials_menu.xml',
'security/ir.model.access.csv',
'group_fields_view.xml',
'security/base_external_referentials_security.xml',
'report_mail_template.xml',
],
'demo_xml': [],
'installable': True,
'certificate': '',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
| # -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2009 Akretion (<http://www.akretion.com>). All Rights Reserved
# authors: Raphaël Valyi, Sharoon Thomas
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Base External Referentials',
'version': '1.0',
'category': 'Generic Modules/Base',
'description': """
Definition : a referential is an external system that will interacts with OpenERP
Goal : store external system connection details and objects fields mapping
This module provide an abstract common minimal base to add any additional external id columns
to some OpenObject table, pointing to some external referential.
A referential is abstract and minimal at this stage, it only has:
* a name
* a location (possibly webservice URL, database connection URL...); the connection method will tell it...
* referential credentials (user name + password)
* placeholders for custom in and out mapping for OpenERP object fields.
OpenERP already has limited supported to external ids using the ir_model_data and the id
fields in the loaded data such as XML or CSV. We think that's OK to store all referential ids
into the same ir_model_data table: yes it makes it large, but synchronisation operations involve
a network bottleneck anyway, so it's largely OK and negligible to have a large table here.
The existing ir_model_data feature of OpenERP is mostly thought as an mono-external referential
(even if the module key of ir_model_data plays some referential scoping role). Here we just push
the concept further to assume multiple external ids for OpenERP entities and add the possibility
to customize their field mapping directly in OpenERP to accomodate the external systems.
""",
'author': 'Raphaël Valyi (Akretion.com), Sharoon Thomas (Openlabs.co.in)',
'website': 'http://www.akretion.com, http://openlabs.co.in/',
'depends': ['base','base_pop_up', 'base_file_protocole', 'email_template'],
'init_xml': [],
'update_xml': [
'external_referentials_view.xml',
'report_view.xml',
'external_referentials_menu.xml',
'security/ir.model.access.csv',
'group_fields_view.xml',
'security/base_external_referentials_security.xml',
'report_mail_template.xml',
],
'demo_xml': [],
'installable': True,
'certificate': '',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
| agpl-3.0 | Python |
6eeb2b4f79c2f735552cf7c061b48425d3299e51 | Use argparse. | nbeaver/equajson | validate_equajson.py | validate_equajson.py | #! /usr/bin/env python3
import json
import jsonschema
import sys
import os
import argparse
def main(equajson_path, schema_path):
global filepath
filepath = equajson_path
with open(schema_path) as schema_file:
try:
equajson_schema = json.load(schema_file)
except:
sys.stderr.write("Invalid JSON in schema: `"+schema_file.name+"'"+'\n')
raise
with open(equajson_path) as json_file:
try:
equajson = json.load(json_file)
except:
sys.stderr.write("Invalid JSON in file: `"+json_file.name+"'"+'\n')
raise
try:
jsonschema.validate(equajson, equajson_schema)
except jsonschema.exceptions.ValidationError:
sys.stderr.write(json_file.name+'\n')
raise
basename_no_extension = os.path.splitext(os.path.basename(json_file.name))[0]
# It's easier to make this a global variable
# than to thread it through every function.
filepath = None
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='validate equajson files')
parser.add_argument(
'-s',
'--schema',
help='path to schema file',
required=True
)
parser.add_argument(
'json_file',
help='path to json file to validate'
)
args = parser.parse_args()
main(args.json_file, args.schema)
| #! /usr/bin/env python3
import json
import jsonschema
import sys
import os
def main(equajson_path, schema_path):
global filepath
filepath = equajson_path
with open(schema_path) as schema_file:
try:
equajson_schema = json.load(schema_file)
except:
sys.stderr.write("Invalid JSON in schema: `"+schema_file.name+"'"+'\n')
raise
with open(equajson_path) as json_file:
try:
equajson = json.load(json_file)
except:
sys.stderr.write("Invalid JSON in file: `"+json_file.name+"'"+'\n')
raise
try:
jsonschema.validate(equajson, equajson_schema)
except jsonschema.exceptions.ValidationError:
sys.stderr.write(json_file.name+'\n')
raise
basename_no_extension = os.path.splitext(os.path.basename(json_file.name))[0]
# It's easier to make this a global variable
# than to thread it through every function.
filepath = None
if __name__ == '__main__':
num_args = len(sys.argv) - 1
if num_args != 2:
sys.stderr.write("Usage: python "+sys.argv[0]+" equajson.json schema.json"+'\n')
sys.exit(1)
main(sys.argv[1], sys.argv[2])
| mit | Python |
e6cb1617e588d6b276fe01c401f2c1b34cf88d5f | fix stuff | dborstelmann/Penguins-GH6,dborstelmann/Penguins-GH6,dborstelmann/Penguins-GH6 | api/read.py | api/read.py | import datetime
from django.http import JsonResponse
from dateutil.parser import parse
from django.contrib.auth.decorators import login_required
from api.models import ( Applicant, Client, Disabilities, EmploymentEducation,
Enrollment, HealthAndDV, IncomeBenefits, Services )
def get_applicants(request):
applicant = {}
return JsonResponse(applicant)
def search_clients(request):
'''
request.POST =
query
'''
clients = Client.objects.all()
if 'query' in request.POST:
q = request.POST['query']
if q.isdigit():
clients = clients.filter(uuid=q)
else:
clients = clients.filter(last_name__contains=q)
return JsonResponse([{
"first_name": c.first_name,
"middle_name": c.middle_name,
"last_name": c.last_name,
"social_security": c.social_security,
"date_of_birth": datetime.datetime.strftime(c.date_of_birth, '%m/%d/%Y'),
"ethnicity": 1,
"gender": 1,
"veteran": 1,
"year_entered": c.year_entered,
"year_exited": c.year_exited,
"date_created": c.date_created
} for c in clients], safe=False)
def get_applicants(request):
app_list = Applicant.objects.all()
applicant = [{
"id": c.id,
"first_name": c.first_name,
"last_name": c.last_name,
"why": c.why,
"phone": c.phone,
"email": c.emial,
"address": c.address,
"birthday": c.birthday,
"ethnicity": value_maps.ethnicity[c.ethnicity],
"gender": value_maps.gender[c.gender],
"veteran": value_maps.veteran[c.veteran],
"family": c.family,
"domestic_violence": value_maps.domestic_violence[c.domestic_violence],
"pregnancy": c.pregnancy,
"drug": c.drug,
"urgency": c.urgency,
"created": c.created,
"reviewed": c.reviewed,
} for c in app_list]
return JsonResponse(applicant, safe=False)
| import datetime
from django.http import JsonResponse
from dateutil.parser import parse
from django.contrib.auth.decorators import login_required
from api.models import ( Applicant, Client, Disabilities, EmploymentEducation,
Enrollment, HealthAndDV, IncomeBenefits, Services )
def get_applicants(request):
applicant = {}
return JsonResponse(applicant)
def search_clients(request):
'''
request.POST =
query
'''
clients = Client.objects.all()
if 'query' in request.POST:
q = request.POST['query']
if q.isdigit():
clients = clients.filter(uuid=q)
else:
clients = clients.filter(last_name__contains=q)
return JsonResponse([{
"first_name": c.first_name,
"middle_name": c.middle_name,
"last_name": c.last_name,
"social_security": c.social_security,
"date_of_birth": datetime.datetime.strftime(c.date_of_birth, '%m/%d/%Y'),
"ethnicity": 1,
"gender": 1,
"veteran": 1,
"year_entered": c.year_entered,
"year_exited": c.year_exited,
"date_created": c.date_created
} for c in clients], safe=False)
<<<<<<< Updated upstream
def get_applicants(request):
app_list = Applicant.objects.all()
applicant = [{
"id": c.id,
"first_name": c.first_name,
"last_name": c.last_name,
"why": c.why,
"phone": c.phone,
"email": c.emial,
"address": c.address,
"birthday": c.birthday,
"ethnicity": value_maps.ethnicity[c.ethnicity],
"gender": value_maps.gender[c.gender],
"veteran": value_maps.veteran[c.veteran],
"family": c.family,
"domestic_violence": value_maps.domestic_violence[c.domestic_violence],
"pregnancy": c.pregnancy,
"drug": c.drug,
"urgency": c.urgency,
"created": c.created,
"reviewed": c.reviewed,
} for c in app_list]
return JsonResponse(applicant, safe=False)
| mit | Python |
ae7b583cab8d38b04ce57571f50221b4a2e429f6 | Update base.py | raiderrobert/django-webhook | webhook/base.py | webhook/base.py | """
Base webhook implementation
"""
import json
from django.http import HttpResponse
from django.views.generic import View
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
class WebhookBase(View):
"""
Simple Webhook base class to handle the most standard case.
"""
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super(WebhookBase, self).dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
data = json.loads(request.body.decode('utf-8'))
self.process_webhook(data)
return HttpResponse(status=200)
def process_webhook(self, data=None):
"""
Unimplemented method
"""
raise NotImplementedError
| """
Base webhook implementation
"""
import json
from django.http import HttpResponse
from django.views.generic import View
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
class WebhookBase(View):
"""
Simple Webhook base class to handle the most standard case.
"""
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super(WebhookBase, self).dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
data = json.loads(request.body.decode('utf-8'))
self.process_webhook(data)
return HttpResponse(status=200)
def process_webhook(self, data):
"""
Unimplemented method
"""
raise NotImplementedError
| mit | Python |
46b860e93d8a9e8dda3499b7306e30ebcd0e0174 | handle session stopped | rohitw1991/frappe,gangadharkadam/tailorfrappe,indictranstech/trufil-frappe,gangadharkadam/vervefrappe,letzerp/framework,gangadhar-kadam/verve_frappe,RicardoJohann/frappe,vjFaLk/frappe,gangadharkadam/v5_frappe,rohitwaghchaure/frappe,suyashphadtare/propshikhari-frappe,saurabh6790/frappe,indictranstech/ebuy-now-frappe,gangadhar-kadam/prjlib,indictranstech/tele-frappe,elba7r/frameworking,gangadharkadam/saloon_frappe_install,saurabh6790/pow-lib,saurabh6790/test_final_med_lib,almeidapaulopt/frappe,deveninfotech/deven-frappe,manassolanki/frappe,saurabh6790/omn-lib,rohitw1991/smartfrappe,RicardoJohann/frappe,MaxMorais/frappe,webnotes/wnframework,gangadharkadam/office_frappe,adityahase/frappe,saurabh6790/tru_lib_back,gangadharkadam/vlinkfrappe,indictranstech/ebuy-now-frappe,BhupeshGupta/frappe,saurabh6790/test-frappe,tmimori/frappe,maxtorete/frappe,Amber-Creative/amber-frappe,saurabh6790/-aimobilize-lib,reachalpineswift/frappe-bench,vCentre/vFRP-6233,gangadharkadam/vlinkfrappe,gangadharkadam/vlinkfrappe,indictranstech/internal-frappe,Amber-Creative/amber-frappe,pawaranand/phr_frappe,indictranstech/omnitech-frappe,elba7r/frameworking,rohitwaghchaure/vestasi-frappe,tundebabzy/frappe,suyashphadtare/sajil-frappe,paurosello/frappe,bohlian/frappe,drukhil/frappe,indictranstech/ebuy-now-frappe,vjFaLk/frappe,gangadharkadam/vervefrappe,rmehta/frappe,anandpdoshi/frappe,gangadharkadam/saloon_frappe,gangadhar-kadam/hrfrappe,rohitwaghchaure/frappe-alec,sbkolate/sap_frappe_v6,rohitwaghchaure/frappe-digitales,saurabh6790/medlib,rkawale/Internalhr-frappe,sbktechnology/trufil-frappe,indictranstech/phr-frappe,MaxMorais/frappe,neilLasrado/frappe,saurabh6790/test-frappe,indictranstech/fbd_frappe,saurabh6790/pow-lib,jevonearth/frappe,gangadharkadam/johnfrappe,gangadharkadam/letzfrappe,mbauskar/omnitech-frappe,rkawale/Internalhr-frappe,praba230890/frappe,saurabh6790/medsynaptic1-lib,saguas/frappe,saurabh6790/test-med-lib,ashokrajbathu/secondrep,sbktechnology/sap_frappe,StrellaGroup/frappe,saurabh6790/omnit-lib,gangadharkadam/smrtfrappe,hatwar/buyback-frappe,paurosello/frappe,rohitwaghchaure/frappe-digitales,suyashphadtare/propshikhari-frappe,ashokrajbathu/secondrep,gangadharkadam/v5_frappe,gangadharkadam/vervefrappe,sbktechnology/sap_frappe,saurabh6790/phr-frappe,tmimori/frappe,indictranstech/omnitech-frappe,shitolepriya/test-frappe,rohitwaghchaure/frappe-digitales,gangadharkadam/vervefrappe,gangadhar-kadam/smrterpfrappe,bohlian/frappe,mbauskar/tele-frappe,indictranstech/frappe,indautgrp/frappe,paurosello/frappe,deveninfotech/deven-frappe,mbauskar/frappe,pawaranand/phr_frappe,neilLasrado/frappe,rohitwaghchaure/New_Theme_frappe,mbauskar/phr-frappe,saurabh6790/test-med-lib,saurabh6790/trufil_lib,saurabh6790/medsynaptic1-lib,Tejal011089/digitales_frappe,erpletzerp/letzerpcore,shitolepriya/test-frappe,jevonearth/frappe,bohlian/frappe,gangadhar-kadam/smrterpfrappe,ESS-LLP/frappe,pranalik/parjanalib,bcornwellmott/frappe,mbauskar/helpdesk-frappe,rohitwaghchaure/frappe-alec,saurabh6790/ON-RISLIB,jevonearth/frappe,gangadharkadam/v5_frappe,indictranstech/osmosis-frappe,gangadharkadam/office_frappe,Tejal011089/digitales_frappe,shitolepriya/test-frappe,sbktechnology/sap_frappe,gangadhar-kadam/verve_frappe,indictranstech/fbd_frappe,gangadharkadam/smrtfrappe,reachalpineswift/frappe-bench,rohitwaghchaure/frappe-digitales,vCentre/vFRP-6233,saurabh6790/aimobilize-lib-backup,pombredanne/frappe,saurabh6790/omnisys-lib,indictranstech/reciphergroup-frappe,indictranstech/internal-frappe,gangadharkadam/stfrappe,indictranstech/osmosis-frappe,gangadhar-kadam/verve_frappe,rohitwaghchaure/frappe-alec,saurabh6790/med_test_lib,ShashaQin/frappe,maxtorete/frappe,gangadhar-kadam/prjlib,vqw/frappe,indictranstech/reciphergroup-frappe,rohitwaghchaure/frappe,saurabh6790/omnisys-lib,nerevu/frappe,gangadharkadam/saloon_frappe,gangadharkadam/frappecontribution,gangadharkadam/frappecontribution,saurabh6790/medsynaptic-lib,erpletzerp/letzerpcore,chdecultot/frappe,shitolepriya/test-frappe,adityahase/frappe,vqw/frappe,hatwar/buyback-frappe,vqw/frappe,maxtorete/frappe,saurabh6790/omnitech-lib,indictranstech/tele-frappe,PriyaShitole/MedViger-lib,indictranstech/osmosis-frappe,tundebabzy/frappe,saurabh6790/med_lib_rels,saurabh6790/omnisys-lib,nerevu/frappe,mbauskar/frappe,Amber-Creative/amber-frappe,gangadhar-kadam/verve_frappe,gangadharkadam/shfr,mbauskar/omnitech-frappe,gangadharkadam/v5_frappe,aboganas/frappe,gangadhar-kadam/verve_live_frappe,suyashphadtare/sajil-final-frappe,deveninfotech/deven-frappe,vqw/frappe,bcornwellmott/frappe,pawaranand/phr-frappe,vCentre/vFRP-6233,MaxMorais/frappe,elba7r/frameworking,mbauskar/frappe,bohlian/frappe,saurabh6790/medsynaptic-lib,saurabh6790/med_new_lib,ShashaQin/frappe,sbkolate/sap_frappe_v6,saurabh6790/tru_lib_back,mbauskar/omnitech-demo-frappe,saurabh6790/med_test_lib,mbauskar/Das_frappe,saurabh6790/omnitech-libs,vCentre/vFRP-6233,aboganas/frappe,mbauskar/phr-frappe,mbauskar/phr-frappe,neilLasrado/frappe,geo-poland/frappe,saurabh6790/omnitech-lib,nabinhait/frappe,manassolanki/frappe,saurabh6790/alert-med-lib,mhbu50/frappe,rohitwaghchaure/frappe,gangadhar-kadam/verve_test_frappe,gangadharkadam/v4_frappe,indictranstech/phr-frappe,suyashphadtare/sajil-frappe,saurabh6790/test-frappe,mbauskar/phr-frappe,letzerp/framework,saurabh6790/medsyn-lib,indictranstech/frappe-digitales,cadencewatches/frappe,gangadhar-kadam/laganfrappe,pombredanne/frappe,yashodhank/frappe,pawaranand/phr_frappe,mbauskar/omnitech-demo-frappe,frappe/frappe,mbauskar/tele-frappe,hernad/frappe,indictranstech/fbd_frappe,gangadharkadam/saloon_frappe_install,mbauskar/helpdesk-frappe,suyashphadtare/sajil-final-frappe,gangadharkadam/v4_frappe,jevonearth/frappe,anandpdoshi/frappe,hernad/frappe,pranalik/frappe-bb,ShashaQin/frappe,ESS-LLP/frappe,rohitw1991/frappe,manassolanki/frappe,saurabh6790/-aimobilize-lib,indictranstech/reciphergroup-frappe,indictranstech/tele-frappe,indictranstech/frappe,bcornwellmott/frappe,suyashphadtare/propshikhari-frappe,saguas/frappe,gangadharkadam/v6_frappe,pombredanne/frappe,saurabh6790/frappe,rohitwaghchaure/New_Theme_frappe,indictranstech/internal-frappe,saurabh6790/aimobilize-lib-backup,indictranstech/frappe,rohitwaghchaure/frappe,indictranstech/trufil-frappe,indictranstech/Das_frappe,gangadhar-kadam/verve_test_frappe,webnotes/wnframework,gangadhar-kadam/nassimlib,gangadhar-kadam/verve_test_frappe,BhupeshGupta/frappe,mbauskar/tele-frappe,mbauskar/Das_frappe,StrellaGroup/frappe,gangadharkadam/letzfrappe,rohitw1991/smartfrappe,tmimori/frappe,saguas/frappe,Tejal011089/digitales_frappe,indictranstech/Das_frappe,RicardoJohann/frappe,suyashphadtare/sajil-frappe,paurosello/frappe,rohitwaghchaure/New_Theme_frappe,indictranstech/fbd_frappe,indictranstech/omnitech-frappe,almeidapaulopt/frappe,StrellaGroup/frappe,gangadhar-kadam/verve_test_frappe,sbktechnology/trufil-frappe,saurabh6790/medlib,webnotes/wnframework,gangadharkadam/saloon_frappe,MaxMorais/frappe,rohitwaghchaure/vestasi-frappe,saurabh6790/OFF-RISLIB,indictranstech/frappe-digitales,vjFaLk/frappe,saurabh6790/alert-med-lib,saurabh6790/frappe,saurabh6790/med_lib_test,saurabh6790/frappe,pranalik/frappe-bb,Tejal011089/medsyn2_lib,gangadharkadam/shfr,sbktechnology/trufil-frappe,drukhil/frappe,hernad/frappe,tmimori/frappe,letzerp/framework,gangadharkadam/v6_frappe,gangadharkadam/saloon_frappe_install,chdecultot/frappe,mbauskar/Das_frappe,pawaranand/phr-frappe,suyashphadtare/propshikhari-frappe,gangadhar-kadam/verve_live_frappe,gangadhar-kadam/lgnlvefrape,pranalik/frappe-bb,praba230890/frappe,saurabh6790/OFF-RISLIB,gangadhar-kadam/laganfrappe,gangadhar-kadam/helpdesk-frappe,ashokrajbathu/secondrep,indictranstech/tele-frappe,gangadharkadam/letzfrappe,erpletzerp/letzerpcore,gangadharkadam/frappecontribution,gangadhar-kadam/hrfrappe,rohitw1991/smarttailorfrappe,gangadharkadam/v6_frappe,yashodhank/frappe,bcornwellmott/frappe,aboganas/frappe,saurabh6790/omni-libs,pawaranand/phr_frappe,mhbu50/frappe,elba7r/builder,tundebabzy/frappe,saurabh6790/omni-libs,rohitwaghchaure/frappe_smart,aboganas/frappe,elba7r/builder,gangadharkadam/tailorfrappe,saurabh6790/phr-frappe,mbauskar/Das_frappe,sbktechnology/sap_frappe,almeidapaulopt/frappe,rmehta/frappe,saurabh6790/medsyn-lib1,indictranstech/Das_frappe,indictranstech/phr-frappe,indictranstech/frappe-digitales,geo-poland/frappe,gangadharkadam/v4_frappe,gangadhar-kadam/lgnlvefrape,saurabh6790/medsyn-lib1,saurabh6790/medsyn-lib,Tejal011089/digitales_frappe,gangadharkadam/johnfrappe,pawaranand/phr-frappe,drukhil/frappe,praba230890/frappe,elba7r/builder,PriyaShitole/MedViger-lib,indautgrp/frappe,gangadhar-kadam/laganfrappe,saurabh6790/trufil_lib,saurabh6790/omnit-lib,gangadhar-kadam/nassimlib,indautgrp/frappe,suyashphadtare/sajil-final-frappe,drukhil/frappe,adityahase/frappe,reachalpineswift/frappe-bench,saurabh6790/med_lib_rels,sbkolate/sap_frappe_v6,anandpdoshi/frappe,yashodhank/frappe,gangadharkadam/v4_frappe,indictranstech/phr-frappe,mhbu50/frappe,BhupeshGupta/frappe,rohitwaghchaure/vestasi-frappe,gangadharkadam/office_frappe,rohitwaghchaure/vestasi-frappe,gangadhar-kadam/helpdesk-frappe,Amber-Creative/amber-frappe,tundebabzy/frappe,ashokrajbathu/secondrep,indictranstech/reciphergroup-frappe,pombredanne/frappe,indautgrp/frappe,nabinhait/frappe,BhupeshGupta/frappe,ESS-LLP/frappe,saguas/frappe,indictranstech/omnitech-frappe,gangadharkadam/saloon_frappe,geo-poland/frappe,gangadhar-kadam/verve_live_frappe,indictranstech/osmosis-frappe,chdecultot/frappe,maxtorete/frappe,vjFaLk/frappe,indictranstech/ebuy-now-frappe,mhbu50/frappe,yashodhank/frappe,ESS-LLP/frappe,gangadharkadam/frappecontribution,pranalik/frappe-bb,mbauskar/frappe,indictranstech/internal-frappe,indictranstech/frappe-digitales,saurabh6790/phr-frappe,mbauskar/omnitech-frappe,mbauskar/tele-frappe,saurabh6790/phr-frappe,saurabh6790/med_new_lib,praba230890/frappe,mbauskar/omnitech-demo-frappe,erpletzerp/letzerpcore,saurabh6790/test-frappe,saurabh6790/med_lib_test,hatwar/buyback-frappe,adityahase/frappe,almeidapaulopt/frappe,gangadhar-kadam/lgnlvefrape,anandpdoshi/frappe,neilLasrado/frappe,gangadharkadam/saloon_frappe_install,cadencewatches/frappe,elba7r/builder,manassolanki/frappe,hernad/frappe,frappe/frappe,mbauskar/helpdesk-frappe,sbktechnology/trufil-frappe,saurabh6790/omnitech-libs,gangadhar-kadam/helpdesk-frappe,letzerp/framework,mbauskar/omnitech-frappe,rohitwaghchaure/frappe_smart,nerevu/frappe,elba7r/frameworking,hatwar/buyback-frappe,saurabh6790/test_final_med_lib,saurabh6790/ON-RISLIB,mbauskar/helpdesk-frappe,mbauskar/omnitech-demo-frappe,sbkolate/sap_frappe_v6,saurabh6790/trufil_lib,rmehta/frappe,saurabh6790/omn-lib,Tejal011089/medsyn2_lib,frappe/frappe,gangadhar-kadam/helpdesk-frappe,gangadhar-kadam/verve_live_frappe,indictranstech/frappe,pranalik/parjanalib,gangadharkadam/letzfrappe,chdecultot/frappe,ShashaQin/frappe,deveninfotech/deven-frappe,indictranstech/Das_frappe,gangadharkadam/vlinkfrappe,indictranstech/trufil-frappe,RicardoJohann/frappe,indictranstech/trufil-frappe,reachalpineswift/frappe-bench,rmehta/frappe,nerevu/frappe,gangadharkadam/v6_frappe,gangadharkadam/stfrappe,rohitw1991/smarttailorfrappe | webnotes/app.py | webnotes/app.py | import sys, os
import json
sys.path.insert(0, '.')
sys.path.insert(0, 'app')
sys.path.insert(0, 'lib')
from werkzeug.wrappers import Request, Response
from werkzeug.local import LocalManager
from webnotes.middlewares import StaticDataMiddleware
from werkzeug.exceptions import HTTPException
from werkzeug.contrib.profiler import ProfilerMiddleware
from webnotes import get_config
import mimetypes
import webnotes
import webnotes.handler
import webnotes.auth
import webnotes.webutils
local_manager = LocalManager([webnotes.local])
def handle_session_stopped():
res = Response("""<html>
<body style="background-color: #EEE;">
<h3 style="width: 900px; background-color: #FFF; border: 2px solid #AAA; padding: 20px; font-family: Arial; margin: 20px auto">
Updating.
We will be back in a few moments...
</h3>
</body>
</html>""")
res.status_code = 503
res.content_type = 'text/html'
return res
@Request.application
def application(request):
webnotes.local.request = request
try:
site = webnotes.utils.get_site_name(request.host)
webnotes.init(site=site)
webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \
for k, v in (request.form or request.args).iteritems() })
webnotes.local._response = Response()
try:
webnotes.http_request = webnotes.auth.HTTPRequest()
except webnotes.AuthenticationError, e:
pass
if webnotes.form_dict.cmd:
webnotes.handler.handle()
else:
webnotes.webutils.render(webnotes.request.path[1:])
except HTTPException, e:
return e
except webnotes.SessionStopped, e:
webnotes.local._response = handle_session_stopped()
finally:
if webnotes.conn:
webnotes.conn.close()
return webnotes.local._response
application = local_manager.make_middleware(application)
def serve(port=8000, profile=False):
webnotes.validate_versions()
global application
from werkzeug.serving import run_simple
if profile:
application = ProfilerMiddleware(application)
application = StaticDataMiddleware(application, {
'/': 'public',
})
run_simple('0.0.0.0', int(port), application, use_reloader=True,
use_debugger=True, use_evalex=True)
| import sys, os
import json
sys.path.insert(0, '.')
sys.path.insert(0, 'app')
sys.path.insert(0, 'lib')
from werkzeug.wrappers import Request, Response
from werkzeug.local import LocalManager
from webnotes.middlewares import StaticDataMiddleware
from werkzeug.exceptions import HTTPException
from werkzeug.contrib.profiler import ProfilerMiddleware
from webnotes import get_config
import mimetypes
import webnotes
import webnotes.handler
import webnotes.auth
import webnotes.webutils
local_manager = LocalManager([webnotes.local])
@Request.application
def application(request):
webnotes.local.request = request
try:
site = webnotes.utils.get_site_name(request.host)
webnotes.init(site=site)
webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \
for k, v in (request.form or request.args).iteritems() })
webnotes.local._response = Response()
try:
webnotes.http_request = webnotes.auth.HTTPRequest()
except webnotes.AuthenticationError, e:
pass
if webnotes.form_dict.cmd:
webnotes.handler.handle()
else:
webnotes.webutils.render(webnotes.request.path[1:])
except HTTPException, e:
return e
finally:
if webnotes.conn:
webnotes.conn.close()
return webnotes._response
application = local_manager.make_middleware(application)
def serve(port=8000, profile=False):
webnotes.validate_versions()
global application
from werkzeug.serving import run_simple
if profile:
application = ProfilerMiddleware(application)
application = StaticDataMiddleware(application, {
'/': 'public',
})
run_simple('0.0.0.0', int(port), application, use_reloader=True,
use_debugger=True, use_evalex=True)
| mit | Python |
e38fa3f55b0e60a1d6c7fa0cf194e6f3bd4b899d | add histogram util | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | corehq/util/datadog/gauges.py | corehq/util/datadog/gauges.py | from functools import wraps
from celery.task import periodic_task
from corehq.util.datadog import statsd, datadog_logger
from corehq.util.soft_assert import soft_assert
def datadog_gauge_task(name, fn, run_every, enforce_prefix='commcare'):
"""
helper for easily registering datadog gauges to run periodically
To update a datadog gauge on a schedule based on the result of a function
just add to your app's tasks.py:
my_calculation = datadog_gauge_task('my.datadog.metric', my_calculation_function,
run_every=crontab(minute=0))
"""
_enforce_prefix(name, enforce_prefix)
datadog_gauge = _DatadogGauge(name, fn, run_every)
return datadog_gauge.periodic_task()
def datadog_histogram(name, value, enforce_prefix='commcare', tags=None):
"""
Usage: Used to track the statistical distribution of a set of values over a statsd flush period.
Actually submits as multiple metrics:
"""
_datadog_record(statsd.histogram, name, value, enforce_prefix, tags)
def datadog_gauge(name, value, enforce_prefix='commcare', tags=None):
_datadog_record(statsd.gauge, name, value, enforce_prefix, tags)
def datadog_counter(name, value=1, enforce_prefix='commcare', tags=None):
_datadog_record(statsd.increment, name, value, enforce_prefix, tags)
def _datadog_record(fn, name, value, enforce_prefix='commcare', tags=None):
_enforce_prefix(name, enforce_prefix)
try:
fn(name, value, tags=tags)
except Exception:
datadog_logger.exception('Unable to record Datadog stats')
class _DatadogGauge(object):
def __init__(self, name, fn, run_every):
self.name = name
self.fn = fn
self.run_every = run_every
def periodic_task(self):
@periodic_task('background_queue', run_every=self.run_every,
acks_late=True, ignore_result=True)
@wraps(self.fn)
def inner(*args, **kwargs):
statsd.gauge(self.name, self.fn(*args, **kwargs))
return inner
def _enforce_prefix(name, prefix):
soft_assert(fail_if_debug=True).call(
not prefix or name.split('.')[0] == prefix,
"Did you mean to call your gauge 'commcare.{}'? "
"If you're sure you want to forgo the prefix, you can "
"pass enforce_prefix=None".format(name))
| from functools import wraps
from celery.task import periodic_task
from corehq.util.datadog import statsd, datadog_logger
from corehq.util.soft_assert import soft_assert
def datadog_gauge_task(name, fn, run_every, enforce_prefix='commcare'):
"""
helper for easily registering datadog gauges to run periodically
To update a datadog gauge on a schedule based on the result of a function
just add to your app's tasks.py:
my_calculation = datadog_gauge_task('my.datadog.metric', my_calculation_function,
run_every=crontab(minute=0))
"""
_enforce_prefix(name, enforce_prefix)
datadog_gauge = _DatadogGauge(name, fn, run_every)
return datadog_gauge.periodic_task()
def datadog_gauge(name, value, enforce_prefix='commcare', tags=None):
_datadog_record(statsd.gauge, name, value, enforce_prefix, tags)
def datadog_counter(name, value=1, enforce_prefix='commcare', tags=None):
_datadog_record(statsd.increment, name, value, enforce_prefix, tags)
def _datadog_record(fn, name, value, enforce_prefix='commcare', tags=None):
_enforce_prefix(name, enforce_prefix)
try:
fn(name, value, tags=tags)
except Exception:
datadog_logger.exception('Unable to record Datadog stats')
class _DatadogGauge(object):
def __init__(self, name, fn, run_every):
self.name = name
self.fn = fn
self.run_every = run_every
def periodic_task(self):
@periodic_task('background_queue', run_every=self.run_every,
acks_late=True, ignore_result=True)
@wraps(self.fn)
def inner(*args, **kwargs):
statsd.gauge(self.name, self.fn(*args, **kwargs))
return inner
def _enforce_prefix(name, prefix):
soft_assert(fail_if_debug=True).call(
not prefix or name.split('.')[0] == prefix,
"Did you mean to call your gauge 'commcare.{}'? "
"If you're sure you want to forgo the prefix, you can "
"pass enforce_prefix=None".format(name))
| bsd-3-clause | Python |
3643f0ce1b7ea7982e8081ae29e726c73471cc4b | update description | tony/vcspull,tony/vcspull | vcspull/__about__.py | vcspull/__about__.py | __title__ = 'vcspull'
__package_name__ = 'vcspull'
__description__ = 'synchronize your repos'
__version__ = '1.0.0'
__author__ = 'Tony Narlock'
__email__ = 'tony@git-pull.com'
__license__ = 'BSD'
__copyright__ = 'Copyright 2013-2016 Tony Narlock'
| __title__ = 'vcspull'
__package_name__ = 'vcspull'
__description__ = 'vcs project manager'
__version__ = '1.0.0'
__author__ = 'Tony Narlock'
__email__ = 'tony@git-pull.com'
__license__ = 'BSD'
__copyright__ = 'Copyright 2013-2016 Tony Narlock'
| mit | Python |
42561d709a2ecfee71103dfbb55116cec1128b71 | fix redirect after upload | ecaldwe1/zika,vecnet/zika,ecaldwe1/zika,vecnet/zika,ecaldwe1/zika,ecaldwe1/zika,ecaldwe1/zika,vecnet/zika,vecnet/zika,vecnet/zika | website/apps/home/views/UploadView.py | website/apps/home/views/UploadView.py | #!/bin/env python2
# -*- coding: utf-8 -*-
#
# This file is part of the VecNet Zika modeling interface.
# For copyright and licensing information about this package, see the
# NOTICE.txt and LICENSE.txt files in its top-level directory; they are
# available at https://github.com/vecnet/zika
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License (MPL), version 2.0. If a copy of the MPL was not distributed
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
import logging
from django.core.urlresolvers import reverse
from django.db import transaction
from django.http.response import HttpResponseBadRequest, HttpResponseRedirect
from django.views.generic.base import TemplateView
from website.apps.home.utils import load_simulation_file
logger = logging.getLogger(__name__)
class UploadView(TemplateView):
template_name = "../templates/simulation/upload.html"
@transaction.atomic
def post(self, request, *args, **kwargs):
if request.method == 'POST':
if not request.FILES['output_file']:
return HttpResponseBadRequest("No 'output_file' is provided")
else:
sim_name = self.request.POST.get(u"name", None)
is_historical = self.request.POST.get("historical")
load_simulation_file(request.FILES['output_file'], simulation_name=sim_name, is_historical=is_historical)
# Redirect to appropriate page whether uploading simulation or historical
if is_historical!='on':
return HttpResponseRedirect(reverse('home.display_simulations'))
else:
return HttpResponseRedirect(reverse('home.display_historical'))
else:
return HttpResponseRedirect("")
| #!/bin/env python2
# -*- coding: utf-8 -*-
#
# This file is part of the VecNet Zika modeling interface.
# For copyright and licensing information about this package, see the
# NOTICE.txt and LICENSE.txt files in its top-level directory; they are
# available at https://github.com/vecnet/zika
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License (MPL), version 2.0. If a copy of the MPL was not distributed
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
import logging
from django.core.urlresolvers import reverse
from django.db import transaction
from django.http.response import HttpResponseBadRequest, HttpResponseRedirect
from django.views.generic.base import TemplateView
from website.apps.home.utils import load_simulation_file
logger = logging.getLogger(__name__)
class UploadView(TemplateView):
template_name = "../templates/simulation/upload.html"
@transaction.atomic
def post(self, request, *args, **kwargs):
if request.method == 'POST':
if not request.FILES['output_file']:
return HttpResponseBadRequest("No 'output_file' is provided")
else:
sim_name = self.request.POST.get(u"name", None)
is_historical = self.request.POST.get("historical")
load_simulation_file(request.FILES['output_file'], simulation_name=sim_name, is_historical=is_historical)
return HttpResponseRedirect(reverse('home.display_simulations'))
else:
return HttpResponseRedirect("")
| mpl-2.0 | Python |
c9a915692b30458717ead2f83fce77ce295e5ed9 | add recipe_folder member (#10527) | conan-io/conan,conan-io/conan,conan-io/conan | conans/pylint_plugin.py | conans/pylint_plugin.py | """Pylint plugin for ConanFile"""
import astroid
from astroid import MANAGER
def register(linter):
"""Declare package as plugin
This function needs to be declared so astroid treats
current file as a plugin.
"""
pass
def transform_conanfile(node):
"""Transform definition of ConanFile class so dynamic fields are visible to pylint"""
str_class = astroid.builtin_lookup("str")
info_class = MANAGER.ast_from_module_name("conans.model.info").lookup(
"ConanInfo")
build_requires_class = MANAGER.ast_from_module_name(
"conans.client.graph.graph_manager").lookup("_RecipeBuildRequires")
file_copier_class = MANAGER.ast_from_module_name(
"conans.client.file_copier").lookup("FileCopier")
file_importer_class = MANAGER.ast_from_module_name(
"conans.client.importer").lookup("_FileImporter")
python_requires_class = MANAGER.ast_from_module_name(
"conans.client.graph.python_requires").lookup("PyRequires")
dynamic_fields = {
"conan_data": str_class,
"build_requires": build_requires_class,
"info_build": info_class,
"info": info_class,
"copy": file_copier_class,
"copy_deps": file_importer_class,
"python_requires": [str_class, python_requires_class],
"recipe_folder": str_class,
}
for f, t in dynamic_fields.items():
node.locals[f] = [t]
MANAGER.register_transform(
astroid.ClassDef, transform_conanfile,
lambda node: node.qname() == "conans.model.conan_file.ConanFile")
def _python_requires_member():
return astroid.parse("""
from conans.client.graph.python_requires import ConanPythonRequire
python_requires = ConanPythonRequire()
""")
astroid.register_module_extender(astroid.MANAGER, "conans", _python_requires_member)
| """Pylint plugin for ConanFile"""
import astroid
from astroid import MANAGER
def register(linter):
"""Declare package as plugin
This function needs to be declared so astroid treats
current file as a plugin.
"""
pass
def transform_conanfile(node):
"""Transform definition of ConanFile class so dynamic fields are visible to pylint"""
str_class = astroid.builtin_lookup("str")
info_class = MANAGER.ast_from_module_name("conans.model.info").lookup(
"ConanInfo")
build_requires_class = MANAGER.ast_from_module_name(
"conans.client.graph.graph_manager").lookup("_RecipeBuildRequires")
file_copier_class = MANAGER.ast_from_module_name(
"conans.client.file_copier").lookup("FileCopier")
file_importer_class = MANAGER.ast_from_module_name(
"conans.client.importer").lookup("_FileImporter")
python_requires_class = MANAGER.ast_from_module_name(
"conans.client.graph.python_requires").lookup("PyRequires")
dynamic_fields = {
"conan_data": str_class,
"build_requires": build_requires_class,
"info_build": info_class,
"info": info_class,
"copy": file_copier_class,
"copy_deps": file_importer_class,
"python_requires": [str_class, python_requires_class],
}
for f, t in dynamic_fields.items():
node.locals[f] = [t]
MANAGER.register_transform(
astroid.ClassDef, transform_conanfile,
lambda node: node.qname() == "conans.model.conan_file.ConanFile")
def _python_requires_member():
return astroid.parse("""
from conans.client.graph.python_requires import ConanPythonRequire
python_requires = ConanPythonRequire()
""")
astroid.register_module_extender(astroid.MANAGER, "conans", _python_requires_member)
| mit | Python |
4b5ae262bab0bc0c83555d39400049f20aaca9cd | Add CONVERSATION_LABEL_MAX_LENGTH constant | vkosuri/ChatterBot,gunthercox/ChatterBot | chatterbot/constants.py | chatterbot/constants.py | """
ChatterBot constants
"""
'''
The maximum length of characters that the text of a statement can contain.
This should be enforced on a per-model basis by the data model for each
storage adapter.
'''
STATEMENT_TEXT_MAX_LENGTH = 400
'''
The maximum length of characters that the text label of a conversation can contain.
The number 32 was chosen because that is the length of the string representation
of a UUID4 with no hyphens.
'''
CONVERSATION_LABEL_MAX_LENGTH = 32
# The maximum length of characters that the name of a tag can contain
TAG_NAME_MAX_LENGTH = 50
DEFAULT_DJANGO_APP_NAME = 'django_chatterbot'
| """
ChatterBot constants
"""
'''
The maximum length of characters that the text of a statement can contain.
This should be enforced on a per-model basis by the data model for each
storage adapter.
'''
STATEMENT_TEXT_MAX_LENGTH = 400
# The maximum length of characters that the name of a tag can contain
TAG_NAME_MAX_LENGTH = 50
DEFAULT_DJANGO_APP_NAME = 'django_chatterbot'
| bsd-3-clause | Python |
7a1e57fa5c6d2c6330a73e8fab95c5ef6fa0ea35 | Fix indentation | thewtex/tomviz,cjh1/tomviz,cjh1/tomviz,mathturtle/tomviz,mathturtle/tomviz,OpenChemistry/tomviz,cryos/tomviz,cryos/tomviz,thewtex/tomviz,OpenChemistry/tomviz,cryos/tomviz,mathturtle/tomviz,OpenChemistry/tomviz,cjh1/tomviz,OpenChemistry/tomviz,thewtex/tomviz | tomviz/python/SetNegativeVoxelsToZero.py | tomviz/python/SetNegativeVoxelsToZero.py | def transform_scalars(dataset):
"""Set negative voxels to zero"""
from tomviz import utils
import numpy as np
data = utils.get_array(dataset)
data[data<0] = 0 #set negative voxels to zero
# set the result as the new scalars.
utils.set_array(dataset, data) | def transform_scalars(dataset):
"""Set negative voxels to zero"""
from tomviz import utils
import numpy as np
data = utils.get_array(dataset)
data[data<0] = 0 #set negative voxels to zero
# set the result as the new scalars.
utils.set_array(dataset, data)
| bsd-3-clause | Python |
46e2997cb51e45dc58f5a97cea6642ba64d03188 | Fix 9.0 version | SerpentCS/purchase-workflow,SerpentCS/purchase-workflow,Eficent/purchase-workflow,SerpentCS/purchase-workflow,Eficent/purchase-workflow | purchase_all_shipments/__openerp__.py | purchase_all_shipments/__openerp__.py | # Author: Leonardo Pistone
# Copyright 2015 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{'name': 'Purchase All Shipments',
'version': '9.0.1.0.0',
'author': "Camptocamp,Odoo Community Association (OCA)",
'category': 'Purchases',
'license': 'AGPL-3',
'depends': ['purchase'],
'data': ['view/purchase_order.xml'],
}
| # Author: Leonardo Pistone
# Copyright 2015 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{'name': 'Purchase All Shipments',
'version': '8.0.1.0.0',
'author': "Camptocamp,Odoo Community Association (OCA)",
'category': 'Purchases',
'license': 'AGPL-3',
'depends': ['purchase'],
'data': ['view/purchase_order.xml'],
}
| agpl-3.0 | Python |
5aca45a68a229f43a25dd97d2c680716c9baabf5 | add travis env to sgen | tz70s/pro-sy-kuo,tz70s/pro-sy-kuo,tz70s/pro-sy-kuo,tz70s/pro-sy-kuo | scripts/sgen.py | scripts/sgen.py | #!/usr/bin/python
# Generate original static file to another with new prefix
# ./sgen index.html old_prefix static_index.html new_prefix
import sys
from os import walk, path, environ
# File lists
# The two file lists should be aligned.
root = environ['TRAVIS_BUILD_DIR']
files = []
for (dirpath, dirname, filenames) in walk( root + "/static"):
for f in filenames:
if ".html" in f:
files.append(dirpath + "/" + f)
# prefix of target files
target_prefix = root + "/docs"
target_files = []
for f in files:
target_files.append(f.replace( root + "/static", target_prefix))
print(target_files)
# Variables of parsing
def parse_args():
if len(sys.argv) < 3:
print ("Not enough arguments")
exit(1)
original_prefix = sys.argv[1]
new_prefix = sys.argv[2]
# unsafe checkout prefix
if original_prefix[0] != 'h' or original_prefix[-1] != '/' or new_prefix[0] != 'h' or new_prefix[-1] != '/':
print ("Seems something wrong on the prefix")
exit(1)
return original_prefix, new_prefix
def sgen():
original_prefix, new_prefix = parse_args()
# parse the publications_ref into the appropriate html format
for i in range(len(files)):
with open(files[i]) as f:
content = f.read()
new_content = content.replace(original_prefix, new_prefix)
with open(target_files[i], "w+") as f:
f.write(new_content)
sgen()
| #!/usr/bin/python
# Generate original static file to another with new prefix
# ./sgen index.html old_prefix static_index.html new_prefix
import sys
from os import walk, path
# File lists
# The two file lists should be aligned.
files = []
for (dirpath, dirname, filenames) in walk("../static"):
for f in filenames:
if ".html" in f:
files.append(dirpath + "/" + f)
# prefix of target files
target_prefix = "../docs"
target_files = []
for f in files:
target_files.append(f.replace("../static", target_prefix))
print(target_files)
# Variables of parsing
def parse_args():
if len(sys.argv) < 3:
print ("Not enough arguments")
exit(1)
original_prefix = sys.argv[1]
new_prefix = sys.argv[2]
# unsafe checkout prefix
if original_prefix[0] != 'h' or original_prefix[-1] != '/' or new_prefix[0] != 'h' or new_prefix[-1] != '/':
print ("Seems something wrong on the prefix")
exit(1)
return original_prefix, new_prefix
def sgen():
original_prefix, new_prefix = parse_args()
# parse the publications_ref into the appropriate html format
for i in range(len(files)):
with open(files[i]) as f:
content = f.read()
new_content = content.replace(original_prefix, new_prefix)
with open(target_files[i], "w+") as f:
f.write(new_content)
sgen() | mit | Python |
24cebbd351875103067162733cf682320df29cf6 | Update VMfileconvert_V2.py | jcornford/pyecog | pyecog/light_code/VMfileconvert_V2.py | pyecog/light_code/VMfileconvert_V2.py | import glob, os, numpy, sys
try:
import stfio
except:
sys.path.append('C:\Python27\Lib\site-packages')
import stfio
def main():
searchpath = os.getcwd()
exportdirectory = searchpath+'/ConvertedFiles/'
# Make export directory
if not os.path.exists(exportdirectory):
os.makedirs(exportdirectory)
# Walk through and find abf files
pattern = '*.abf'
datafilenames = glob.glob(pattern)
if datafilenames:
for filename in datafilenames:
print ('Converting '+str(filename))
data = stfio.read(filename,ftype = "abf")
x = data.aspandas()
x = x.values
numpy.save(exportdirectory+filename[0:-4],x)
if __name__ == '__main__':
main()
| import glob, os, numpy
import stfio
def main():
searchpath = os.getcwd()
exportdirectory = searchpath+'/ConvertedFiles/'
# Make export directory
if not os.path.exists(exportdirectory):
os.makedirs(exportdirectory)
# Walk through and find abf files
pattern = '*.abf'
datafilenames = glob.glob(pattern)
if datafilenames:
for filename in datafilenames:
print ('Converting '+str(filename))
data = stfio.read(filename,ftype = "abf")
x = data.aspandas()
x = x.values
numpy.save(exportdirectory+filename[0:-4],x)
if __name__ == '__main__':
main()
| mit | Python |
393bde7e7f3902f734e8c01f265b216f2d3eef26 | remove leftover | DUlSine/DUlSine,DUlSine/DUlSine | models/dulsine_commons.py | models/dulsine_commons.py | # -*- coding: utf-8 -*-
# vim: set ts=4
# Common enumerations used in some places
CIVILITES = (
('M.', 'Monsieur'),
('Mme', 'Madame'),
('Mlle', 'Mademoiselle')
)
CIRCUITS = (
('O', 'ouvert'),
('F', 'ferme'),
('N', 'pas de circuit')
)
TYPES_ACTEURS = (
('P', 'Professionnels'),
('A', 'Amateurs'),
('M', 'Mixte')
)
TEAM_TYPES = (
(0, 'PAPS'),
(1, 'Equipe'),
(2, 'Binome'),
(3, 'Equipe d\'Evacuation')
)
DIPLOME_CI = 0
DIPLOME_PSE2 = 1
DIPLOME_PSE1 = 2
DIPLOME_PSC1 = 3
DIPLOME_SECOURS = (
(DIPLOME_CI, 'CI'),
(DIPLOME_PSE2, 'PSE2'),
(DIPLOME_PSE1, 'PSE1'),
(DIPLOME_PSC1, 'PSC1'),
(4, 'IPS'),
(5, 'CDPE')
)
DIPLOME_CONDUCTEURS = (
(10, 'CH'),
(11, 'CHA'),
(12, '4x4')
)
DIPLOME_FORMATEURS = (
(20, 'FCI'),
(21, 'PAE1'),
(22, 'PAE2'),
(23, 'PAE3'),
(24, 'PAE4'),
)
FORMATIONS = DIPLOME_SECOURS + DIPLOME_CONDUCTEURS + DIPLOME_FORMATEURS
WISH_ND = 0
WISH_CHOICES = (
(WISH_ND, 'N.D.'),
(1, 'Disponible'),
(2, 'Intéressé'),
(3, 'Très intéressé'),
)
| # -*- coding: utf-8 -*-
# vim: set ts=4
# Common enumerations used in some places
CIVILITES = (
('M.', 'Monsieur'),
('Mme', 'Madame'),
('Mlle', 'Mademoiselle')
)
CIRCUITS = (
('O', 'ouvert'),
('F', 'ferme'),
('N', 'pas de circuit')
)
TYPES_ACTEURS = (
('P', 'Professionnels'),
('A', 'Amateurs'),
('M', 'Mixte')
)
TEAM_TYPES = (
(0, 'PAPS'),
(1, 'Equipe'),
(2, 'Binome'),
(3, 'Equipe d\'Evacuation')
)
DIPLOME_SECOURS = (
(0, 'N.D.'),
(1, 'CI'),
(2, 'PSE2'),
(3, 'PSE1'),
(4, 'PSC1'),
(5, 'IPS'),
(6, 'CDPE')
)
NOT_AVAILABLE = 0
DIPLOME_CI = 1
DIPLOME_PSE2 = 2
DIPLOME_PSE1 = 3
DIPLOME_PSC1 = 4
DIPLOME_CONDUCTEURS = (
(10, 'CH'),
(11, 'CHA'),
(12, '4x4')
)
DIPLOME_FORMATEURS = (
(20, 'FCI'),
(21, 'PAE1'),
(22, 'PAE2'),
(23, 'PAE3'),
(24, 'PAE4'),
)
FORMATIONS = DIPLOME_SECOURS + DIPLOME_CONDUCTEURS + DIPLOME_FORMATEURS
WISH_ND = 0
WISH_CHOICES = (
(WISH_ND, 'N.D.'),
(1, 'Disponible'),
(2, 'Intéressé'),
(3, 'Très intéressé'),
)
| agpl-3.0 | Python |
f9a99102a7053e444021926d08750f04a662fd9f | remove unnecessary print statements | jmfranck/pyspecdata,jmfranck/pyspecdata,jmfranck/pyspecdata,jmfranck/pyspecdata | pyspecdata/load_files/open_subpath.py | pyspecdata/load_files/open_subpath.py | from ..core import *
from ..datadir import dirformat
import os.path
from zipfile import ZipFile
def open_subpath(file_reference,*subpath,**kwargs):
"""
Parameters
----------
file_reference: str or tuple
If a string, then it's the name of a directory.
If it's a tuple, then, it has three elements: the ZipFile object, the
filename of the zip file (for reference), and the name of the file we're interested in
within the zip file.
test_only: bool
just test if the path exists
"""
mode,test_only = process_kwargs([('mode','r'),
('test_only',False)],kwargs)
if isinstance(file_reference,basestring):
if test_only:
full_path = os.path.join(file_reference, *subpath)
if os.path.exists(full_path):
return True
else:
return False
else:
fp = open(os.path.join(file_reference,*subpath),mode)
else:
if type(file_reference) == tuple:
if len(file_reference) == 3 and type(file_reference[0]) is ZipFile:
zf = file_reference[0]
zip_basename = file_reference[1]
name_inside_zip = file_reference[2]
subfile = '/'.join((name_inside_zip,)+subpath)
if test_only:
if subfile in zf.namelist():
return True
else:
return False
if subfile in zf.namelist():
return zf.open(subfile)
else:
raise ValueError(subfile+" not found in zip file")
else:
raise ValueError("open_subpath doesn't understand the format of the tuple passe to file_reference")
else:
raise ValueError("open_subpath doesn't understand the type of the file_reference")
return fp
| from ..core import *
from ..datadir import dirformat
import os.path
from zipfile import ZipFile
def open_subpath(file_reference,*subpath,**kwargs):
"""
Parameters
----------
file_reference: str or tuple
If a string, then it's the name of a directory.
If it's a tuple, then, it has three elements: the ZipFile object, the
filename of the zip file (for reference), and the name of the file we're interested in
within the zip file.
test_only: bool
just test if the path exists
"""
mode,test_only = process_kwargs([('mode','r'),
('test_only',False)],kwargs)
if isinstance(file_reference,basestring):
if test_only:
print "testing",(file_reference,) + subpath
full_path = os.path.join(file_reference, *subpath)
if os.path.exists(full_path):
return True
else:
return False
else:
fp = open(os.path.join(file_reference,*subpath),mode)
else:
if type(file_reference) == tuple:
if len(file_reference) == 3 and type(file_reference[0]) is ZipFile:
zf = file_reference[0]
zip_basename = file_reference[1]
name_inside_zip = file_reference[2]
subfile = '/'.join((name_inside_zip,)+subpath)
if test_only:
if subfile in zf.namelist():
return True
else:
return False
if subfile in zf.namelist():
return zf.open(subfile)
else:
raise ValueError(subfile+" not found in zip file")
else:
raise ValueError("open_subpath doesn't understand the format of the tuple passe to file_reference")
else:
raise ValueError("open_subpath doesn't understand the type of the file_reference")
return fp
| bsd-3-clause | Python |
ba370231fe80280dec806c7c2515061e8607b360 | Add SCA into mbio | wzmao/mbio,wzmao/mbio,wzmao/mbio | Correlation/__init__.py | Correlation/__init__.py | __author__ = 'Wenzhi Mao'
__all__ = []
def _Startup():
from mbio import _ABSpath
global _path__
_path__ = _ABSpath()
from os import path
Clist = ['mi.c', 'omes.c']
for c in Clist:
if not path.exists(_path__+'/'+c.replace('.c', '_c.so')):
from mbio import _make
_make(_path__+'/'+c)
_Startup()
from . import MI
from .MI import *
__all__.extend(MI.__all__)
from . import OMES
from .OMES import *
__all__.extend(OMES.__all__)
from . import SCA
from .SCA import *
__all__.extend(SCA.__all__) | __author__ = 'Wenzhi Mao'
__all__ = []
def _Startup():
from mbio import _ABSpath
global _path__
_path__ = _ABSpath()
from os import path
Clist = ['mi.c', 'omes.c']
for c in Clist:
if not path.exists(_path__+'/'+c.replace('.c', '_c.so')):
from mbio import _make
_make(_path__+'/'+c)
_Startup()
from . import MI
from .MI import *
__all__.extend(MI.__all__)
from . import OMES
from .OMES import *
__all__.extend(OMES.__all__)
| mit | Python |
2277c82efdc456e5873987eabac88810b2cece5b | Fix pep8 whitespace violation. | chauhanhardik/populo,openfun/edx-platform,gsehub/edx-platform,Edraak/circleci-edx-platform,chauhanhardik/populo_2,simbs/edx-platform,nikolas/edx-platform,mcgachey/edx-platform,rue89-tech/edx-platform,AkA84/edx-platform,synergeticsedx/deployment-wipro,4eek/edx-platform,LICEF/edx-platform,TeachAtTUM/edx-platform,JCBarahona/edX,MSOpenTech/edx-platform,eduNEXT/edx-platform,praveen-pal/edx-platform,kursitet/edx-platform,chudaol/edx-platform,zubair-arbi/edx-platform,chudaol/edx-platform,edry/edx-platform,martynovp/edx-platform,chand3040/cloud_that,nttks/jenkins-test,alexthered/kienhoc-platform,abdoosh00/edx-rtl-final,chauhanhardik/populo,doganov/edx-platform,abdoosh00/edraak,peterm-itr/edx-platform,doismellburning/edx-platform,polimediaupv/edx-platform,don-github/edx-platform,iivic/BoiseStateX,simbs/edx-platform,hamzehd/edx-platform,ferabra/edx-platform,wwj718/edx-platform,CredoReference/edx-platform,unicri/edx-platform,eestay/edx-platform,Unow/edx-platform,sameetb-cuelogic/edx-platform-test,bitifirefly/edx-platform,TsinghuaX/edx-platform,RPI-OPENEDX/edx-platform,carsongee/edx-platform,pdehaye/theming-edx-platform,unicri/edx-platform,beacloudgenius/edx-platform,lduarte1991/edx-platform,IONISx/edx-platform,Softmotions/edx-platform,shashank971/edx-platform,atsolakid/edx-platform,proversity-org/edx-platform,PepperPD/edx-pepper-platform,nttks/edx-platform,CourseTalk/edx-platform,nanolearning/edx-platform,raccoongang/edx-platform,utecuy/edx-platform,defance/edx-platform,edx-solutions/edx-platform,cyanna/edx-platform,dcosentino/edx-platform,abdoosh00/edraak,kxliugang/edx-platform,sameetb-cuelogic/edx-platform-test,chauhanhardik/populo_2,rhndg/openedx,BehavioralInsightsTeam/edx-platform,shabab12/edx-platform,xinjiguaike/edx-platform,deepsrijit1105/edx-platform,ak2703/edx-platform,unicri/edx-platform,WatanabeYasumasa/edx-platform,zofuthan/edx-platform,eemirtekin/edx-platform,wwj718/edx-platform,shubhdev/edxOnBaadal,vasyarv/edx-platform,kamalx/edx-platform,zubair-arbi/edx-platform,wwj718/edx-platform,morpheby/levelup-by,nanolearningllc/edx-platform-cypress-2,fly19890211/edx-platform,EduPepperPDTesting/pepper2013-testing,mitocw/edx-platform,itsjeyd/edx-platform,BehavioralInsightsTeam/edx-platform,romain-li/edx-platform,etzhou/edx-platform,shabab12/edx-platform,hkawasaki/kawasaki-aio8-1,xuxiao19910803/edx-platform,kxliugang/edx-platform,hamzehd/edx-platform,msegado/edx-platform,synergeticsedx/deployment-wipro,auferack08/edx-platform,openfun/edx-platform,olexiim/edx-platform,gsehub/edx-platform,deepsrijit1105/edx-platform,MakeHer/edx-platform,don-github/edx-platform,analyseuc3m/ANALYSE-v1,nttks/edx-platform,MakeHer/edx-platform,shubhdev/openedx,analyseuc3m/ANALYSE-v1,xuxiao19910803/edx-platform,prarthitm/edxplatform,deepsrijit1105/edx-platform,edry/edx-platform,benpatterson/edx-platform,gymnasium/edx-platform,doganov/edx-platform,motion2015/a3,jamiefolsom/edx-platform,J861449197/edx-platform,adoosii/edx-platform,gymnasium/edx-platform,miptliot/edx-platform,cselis86/edx-platform,chand3040/cloud_that,carsongee/edx-platform,rationalAgent/edx-platform-custom,zofuthan/edx-platform,appliedx/edx-platform,EDUlib/edx-platform,ovnicraft/edx-platform,mjirayu/sit_academy,WatanabeYasumasa/edx-platform,caesar2164/edx-platform,jamesblunt/edx-platform,rismalrv/edx-platform,stvstnfrd/edx-platform,IITBinterns13/edx-platform-dev,cyanna/edx-platform,jswope00/griffinx,Lektorium-LLC/edx-platform,playm2mboy/edx-platform,prarthitm/edxplatform,EduPepperPDTesting/pepper2013-testing,amir-qayyum-khan/edx-platform,mushtaqak/edx-platform,don-github/edx-platform,iivic/BoiseStateX,Endika/edx-platform,unicri/edx-platform,beni55/edx-platform,prarthitm/edxplatform,itsjeyd/edx-platform,jelugbo/tundex,mtlchun/edx,motion2015/edx-platform,olexiim/edx-platform,mcgachey/edx-platform,gsehub/edx-platform,dsajkl/123,zadgroup/edx-platform,jazkarta/edx-platform,ZLLab-Mooc/edx-platform,vikas1885/test1,rationalAgent/edx-platform-custom,ESOedX/edx-platform,syjeon/new_edx,mjirayu/sit_academy,praveen-pal/edx-platform,jamesblunt/edx-platform,rhndg/openedx,ampax/edx-platform,nagyistoce/edx-platform,nagyistoce/edx-platform,jolyonb/edx-platform,IONISx/edx-platform,ubc/edx-platform,appsembler/edx-platform,adoosii/edx-platform,kmoocdev2/edx-platform,nikolas/edx-platform,atsolakid/edx-platform,hkawasaki/kawasaki-aio8-2,wwj718/edx-platform,msegado/edx-platform,alu042/edx-platform,ampax/edx-platform,amir-qayyum-khan/edx-platform,ak2703/edx-platform,sameetb-cuelogic/edx-platform-test,ampax/edx-platform-backup,xuxiao19910803/edx,utecuy/edx-platform,bitifirefly/edx-platform,jswope00/griffinx,eduNEXT/edx-platform,olexiim/edx-platform,cpennington/edx-platform,ovnicraft/edx-platform,shubhdev/edxOnBaadal,naresh21/synergetics-edx-platform,procangroup/edx-platform,Kalyzee/edx-platform,ESOedX/edx-platform,jelugbo/tundex,lduarte1991/edx-platform,Edraak/circleci-edx-platform,jazkarta/edx-platform,jazztpt/edx-platform,EduPepperPD/pepper2013,CourseTalk/edx-platform,J861449197/edx-platform,IndonesiaX/edx-platform,caesar2164/edx-platform,zhenzhai/edx-platform,nanolearningllc/edx-platform-cypress,franosincic/edx-platform,dkarakats/edx-platform,mitocw/edx-platform,inares/edx-platform,jelugbo/tundex,louyihua/edx-platform,raccoongang/edx-platform,DefyVentures/edx-platform,Shrhawk/edx-platform,knehez/edx-platform,miptliot/edx-platform,tanmaykm/edx-platform,apigee/edx-platform,motion2015/a3,yokose-ks/edx-platform,Softmotions/edx-platform,nttks/jenkins-test,dkarakats/edx-platform,knehez/edx-platform,ZLLab-Mooc/edx-platform,CredoReference/edx-platform,don-github/edx-platform,marcore/edx-platform,nagyistoce/edx-platform,pelikanchik/edx-platform,doismellburning/edx-platform,arifsetiawan/edx-platform,pelikanchik/edx-platform,mbareta/edx-platform-ft,mitocw/edx-platform,mahendra-r/edx-platform,alexthered/kienhoc-platform,Unow/edx-platform,vismartltd/edx-platform,devs1991/test_edx_docmode,pomegranited/edx-platform,pabloborrego93/edx-platform,jazkarta/edx-platform,UOMx/edx-platform,jbzdak/edx-platform,IONISx/edx-platform,chand3040/cloud_that,zubair-arbi/edx-platform,leansoft/edx-platform,analyseuc3m/ANALYSE-v1,mjirayu/sit_academy,edx/edx-platform,10clouds/edx-platform,inares/edx-platform,vasyarv/edx-platform,arifsetiawan/edx-platform,leansoft/edx-platform,kmoocdev/edx-platform,UOMx/edx-platform,pepeportela/edx-platform,edx/edx-platform,olexiim/edx-platform,kalebhartje/schoolboost,ampax/edx-platform-backup,jamiefolsom/edx-platform,analyseuc3m/ANALYSE-v1,lduarte1991/edx-platform,10clouds/edx-platform,antoviaque/edx-platform,y12uc231/edx-platform,shubhdev/edx-platform,alu042/edx-platform,chauhanhardik/populo,JCBarahona/edX,beni55/edx-platform,raccoongang/edx-platform,mushtaqak/edx-platform,MSOpenTech/edx-platform,defance/edx-platform,procangroup/edx-platform,zhenzhai/edx-platform,jelugbo/tundex,morpheby/levelup-by,dcosentino/edx-platform,syjeon/new_edx,tiagochiavericosta/edx-platform,bdero/edx-platform,SivilTaram/edx-platform,Livit/Livit.Learn.EdX,defance/edx-platform,msegado/edx-platform,pdehaye/theming-edx-platform,rismalrv/edx-platform,kmoocdev/edx-platform,hastexo/edx-platform,mushtaqak/edx-platform,abdoosh00/edraak,romain-li/edx-platform,vasyarv/edx-platform,sudheerchintala/LearnEraPlatForm,Edraak/circleci-edx-platform,a-parhom/edx-platform,y12uc231/edx-platform,ahmadio/edx-platform,Endika/edx-platform,zerobatu/edx-platform,franosincic/edx-platform,cselis86/edx-platform,iivic/BoiseStateX,jswope00/GAI,synergeticsedx/deployment-wipro,UXE/local-edx,edx-solutions/edx-platform,torchingloom/edx-platform,bigdatauniversity/edx-platform,morenopc/edx-platform,eduNEXT/edx-platform,BehavioralInsightsTeam/edx-platform,jswope00/GAI,antonve/s4-project-mooc,carsongee/edx-platform,DefyVentures/edx-platform,ahmedaljazzar/edx-platform,antonve/s4-project-mooc,vikas1885/test1,ferabra/edx-platform,Kalyzee/edx-platform,angelapper/edx-platform,ovnicraft/edx-platform,B-MOOC/edx-platform,romain-li/edx-platform,xingyepei/edx-platform,CredoReference/edx-platform,Endika/edx-platform,apigee/edx-platform,CourseTalk/edx-platform,tanmaykm/edx-platform,TeachAtTUM/edx-platform,edry/edx-platform,xuxiao19910803/edx,TsinghuaX/edx-platform,xuxiao19910803/edx,MSOpenTech/edx-platform,mushtaqak/edx-platform,stvstnfrd/edx-platform,IndonesiaX/edx-platform,AkA84/edx-platform,prarthitm/edxplatform,hkawasaki/kawasaki-aio8-1,praveen-pal/edx-platform,philanthropy-u/edx-platform,cselis86/edx-platform,miptliot/edx-platform,JCBarahona/edX,vikas1885/test1,beni55/edx-platform,EduPepperPDTesting/pepper2013-testing,cognitiveclass/edx-platform,knehez/edx-platform,ahmadiga/min_edx,eduNEXT/edx-platform,edx-solutions/edx-platform,eemirtekin/edx-platform,Edraak/edraak-platform,jazkarta/edx-platform-for-isc,teltek/edx-platform,ahmadio/edx-platform,chauhanhardik/populo_2,adoosii/edx-platform,pku9104038/edx-platform,etzhou/edx-platform,ahmadio/edx-platform,SravanthiSinha/edx-platform,eduNEXT/edunext-platform,pelikanchik/edx-platform,longmen21/edx-platform,a-parhom/edx-platform,jjmiranda/edx-platform,cpennington/edx-platform,dkarakats/edx-platform,doismellburning/edx-platform,OmarIthawi/edx-platform,chudaol/edx-platform,Softmotions/edx-platform,jjmiranda/edx-platform,solashirai/edx-platform,proversity-org/edx-platform,vasyarv/edx-platform,morpheby/levelup-by,hamzehd/edx-platform,valtech-mooc/edx-platform,syjeon/new_edx,CredoReference/edx-platform,nikolas/edx-platform,cecep-edu/edx-platform,fly19890211/edx-platform,jelugbo/tundex,sameetb-cuelogic/edx-platform-test,franosincic/edx-platform,proversity-org/edx-platform,shurihell/testasia,TsinghuaX/edx-platform,sudheerchintala/LearnEraPlatForm,Kalyzee/edx-platform,cognitiveclass/edx-platform,ahmedaljazzar/edx-platform,arbrandes/edx-platform,JioEducation/edx-platform,bdero/edx-platform,alexthered/kienhoc-platform,DNFcode/edx-platform,ahmadiga/min_edx,bigdatauniversity/edx-platform,pdehaye/theming-edx-platform,jamiefolsom/edx-platform,CourseTalk/edx-platform,ovnicraft/edx-platform,devs1991/test_edx_docmode,amir-qayyum-khan/edx-platform,EduPepperPDTesting/pepper2013-testing,rhndg/openedx,LICEF/edx-platform,mjirayu/sit_academy,philanthropy-u/edx-platform,jazkarta/edx-platform-for-isc,LICEF/edx-platform,tiagochiavericosta/edx-platform,mtlchun/edx,Semi-global/edx-platform,nttks/jenkins-test,jswope00/griffinx,IndonesiaX/edx-platform,simbs/edx-platform,hkawasaki/kawasaki-aio8-0,shubhdev/openedx,philanthropy-u/edx-platform,rationalAgent/edx-platform-custom,andyzsf/edx,eestay/edx-platform,zhenzhai/edx-platform,Edraak/edx-platform,beacloudgenius/edx-platform,halvertoluke/edx-platform,AkA84/edx-platform,unicri/edx-platform,waheedahmed/edx-platform,syjeon/new_edx,jonathan-beard/edx-platform,longmen21/edx-platform,jolyonb/edx-platform,shubhdev/edxOnBaadal,apigee/edx-platform,dsajkl/123,jbassen/edx-platform,procangroup/edx-platform,xinjiguaike/edx-platform,inares/edx-platform,xuxiao19910803/edx-platform,peterm-itr/edx-platform,eestay/edx-platform,Semi-global/edx-platform,chauhanhardik/populo_2,mahendra-r/edx-platform,atsolakid/edx-platform,ZLLab-Mooc/edx-platform,jruiperezv/ANALYSE,TeachAtTUM/edx-platform,xinjiguaike/edx-platform,naresh21/synergetics-edx-platform,nanolearning/edx-platform,kursitet/edx-platform,rhndg/openedx,torchingloom/edx-platform,EduPepperPD/pepper2013,nanolearningllc/edx-platform-cypress,iivic/BoiseStateX,Shrhawk/edx-platform,ampax/edx-platform,hmcmooc/muddx-platform,jbzdak/edx-platform,itsjeyd/edx-platform,kmoocdev2/edx-platform,jzoldak/edx-platform,bitifirefly/edx-platform,bitifirefly/edx-platform,valtech-mooc/edx-platform,dkarakats/edx-platform,PepperPD/edx-pepper-platform,UXE/local-edx,bigdatauniversity/edx-platform,arifsetiawan/edx-platform,LearnEra/LearnEraPlaftform,wwj718/ANALYSE,jamesblunt/edx-platform,jbzdak/edx-platform,morenopc/edx-platform,jonathan-beard/edx-platform,B-MOOC/edx-platform,hkawasaki/kawasaki-aio8-0,chauhanhardik/populo,nanolearningllc/edx-platform-cypress-2,shubhdev/edxOnBaadal,arbrandes/edx-platform,4eek/edx-platform,shashank971/edx-platform,rue89-tech/edx-platform,shubhdev/edx-platform,hkawasaki/kawasaki-aio8-1,halvertoluke/edx-platform,msegado/edx-platform,mcgachey/edx-platform,teltek/edx-platform,antonve/s4-project-mooc,playm2mboy/edx-platform,antoviaque/edx-platform,rue89-tech/edx-platform,jruiperezv/ANALYSE,chauhanhardik/populo_2,dsajkl/123,shashank971/edx-platform,dkarakats/edx-platform,nanolearningllc/edx-platform-cypress-2,abdoosh00/edraak,Lektorium-LLC/edx-platform,waheedahmed/edx-platform,shashank971/edx-platform,etzhou/edx-platform,jazztpt/edx-platform,Unow/edx-platform,SivilTaram/edx-platform,stvstnfrd/edx-platform,nttks/edx-platform,franosincic/edx-platform,Edraak/edx-platform,jamiefolsom/edx-platform,mtlchun/edx,mbareta/edx-platform-ft,peterm-itr/edx-platform,appsembler/edx-platform,jbzdak/edx-platform,nttks/edx-platform,UXE/local-edx,nanolearningllc/edx-platform-cypress-2,Edraak/edraak-platform,cecep-edu/edx-platform,Softmotions/edx-platform,louyihua/edx-platform,shurihell/testasia,Livit/Livit.Learn.EdX,cognitiveclass/edx-platform,a-parhom/edx-platform,ZLLab-Mooc/edx-platform,Ayub-Khan/edx-platform,halvertoluke/edx-platform,RPI-OPENEDX/edx-platform,cecep-edu/edx-platform,mitocw/edx-platform,nanolearningllc/edx-platform-cypress,ahmedaljazzar/edx-platform,ak2703/edx-platform,xinjiguaike/edx-platform,hkawasaki/kawasaki-aio8-0,leansoft/edx-platform,auferack08/edx-platform,devs1991/test_edx_docmode,kmoocdev/edx-platform,vasyarv/edx-platform,shubhdev/openedx,AkA84/edx-platform,martynovp/edx-platform,SivilTaram/edx-platform,nanolearning/edx-platform,auferack08/edx-platform,mushtaqak/edx-platform,kalebhartje/schoolboost,pelikanchik/edx-platform,Edraak/edraak-platform,arbrandes/edx-platform,shabab12/edx-platform,proversity-org/edx-platform,zubair-arbi/edx-platform,kxliugang/edx-platform,sudheerchintala/LearnEraPlatForm,dsajkl/reqiop,eduNEXT/edunext-platform,fly19890211/edx-platform,jbzdak/edx-platform,jzoldak/edx-platform,itsjeyd/edx-platform,msegado/edx-platform,mjg2203/edx-platform-seas,LearnEra/LearnEraPlaftform,polimediaupv/edx-platform,cyanna/edx-platform,kmoocdev2/edx-platform,marcore/edx-platform,morenopc/edx-platform,DefyVentures/edx-platform,abdoosh00/edx-rtl-final,Lektorium-LLC/edx-platform,SivilTaram/edx-platform,cselis86/edx-platform,EduPepperPD/pepper2013,solashirai/edx-platform,inares/edx-platform,dcosentino/edx-platform,edx/edx-platform,procangroup/edx-platform,Stanford-Online/edx-platform,kmoocdev2/edx-platform,arbrandes/edx-platform,simbs/edx-platform,4eek/edx-platform,peterm-itr/edx-platform,utecuy/edx-platform,bigdatauniversity/edx-platform,olexiim/edx-platform,mjg2203/edx-platform-seas,EduPepperPD/pepper2013,Unow/edx-platform,Livit/Livit.Learn.EdX,y12uc231/edx-platform,jswope00/GAI,inares/edx-platform,zadgroup/edx-platform,DNFcode/edx-platform,hkawasaki/kawasaki-aio8-2,dsajkl/reqiop,TsinghuaX/edx-platform,mcgachey/edx-platform,OmarIthawi/edx-platform,doganov/edx-platform,rismalrv/edx-platform,IITBinterns13/edx-platform-dev,MakeHer/edx-platform,mahendra-r/edx-platform,Semi-global/edx-platform,dsajkl/reqiop,ferabra/edx-platform,ampax/edx-platform-backup,bdero/edx-platform,jazztpt/edx-platform,xingyepei/edx-platform,mjg2203/edx-platform-seas,polimediaupv/edx-platform,adoosii/edx-platform,shurihell/testasia,wwj718/ANALYSE,Stanford-Online/edx-platform,pabloborrego93/edx-platform,JioEducation/edx-platform,etzhou/edx-platform,devs1991/test_edx_docmode,cyanna/edx-platform,pomegranited/edx-platform,pepeportela/edx-platform,WatanabeYasumasa/edx-platform,yokose-ks/edx-platform,naresh21/synergetics-edx-platform,hmcmooc/muddx-platform,halvertoluke/edx-platform,4eek/edx-platform,ovnicraft/edx-platform,yokose-ks/edx-platform,hastexo/edx-platform,beacloudgenius/edx-platform,mtlchun/edx,xingyepei/edx-platform,dcosentino/edx-platform,jazztpt/edx-platform,ak2703/edx-platform,PepperPD/edx-pepper-platform,10clouds/edx-platform,eemirtekin/edx-platform,J861449197/edx-platform,torchingloom/edx-platform,hkawasaki/kawasaki-aio8-2,doismellburning/edx-platform,SravanthiSinha/edx-platform,Stanford-Online/edx-platform,simbs/edx-platform,hkawasaki/kawasaki-aio8-0,devs1991/test_edx_docmode,cecep-edu/edx-platform,Edraak/edx-platform,OmarIthawi/edx-platform,zadgroup/edx-platform,etzhou/edx-platform,ahmadiga/min_edx,rismalrv/edx-platform,xinjiguaike/edx-platform,beni55/edx-platform,defance/edx-platform,zhenzhai/edx-platform,kamalx/edx-platform,kursitet/edx-platform,wwj718/ANALYSE,cpennington/edx-platform,ampax/edx-platform,Edraak/edraak-platform,motion2015/edx-platform,don-github/edx-platform,Shrhawk/edx-platform,fintech-circle/edx-platform,Edraak/circleci-edx-platform,jjmiranda/edx-platform,JioEducation/edx-platform,waheedahmed/edx-platform,devs1991/test_edx_docmode,openfun/edx-platform,tiagochiavericosta/edx-platform,yokose-ks/edx-platform,dsajkl/123,J861449197/edx-platform,tanmaykm/edx-platform,morenopc/edx-platform,JCBarahona/edX,zadgroup/edx-platform,torchingloom/edx-platform,Ayub-Khan/edx-platform,vikas1885/test1,hmcmooc/muddx-platform,alu042/edx-platform,xuxiao19910803/edx-platform,chrisndodge/edx-platform,nanolearningllc/edx-platform-cypress-2,hastexo/edx-platform,openfun/edx-platform,marcore/edx-platform,torchingloom/edx-platform,tanmaykm/edx-platform,Ayub-Khan/edx-platform,Softmotions/edx-platform,hamzehd/edx-platform,benpatterson/edx-platform,motion2015/a3,IONISx/edx-platform,LICEF/edx-platform,appliedx/edx-platform,mbareta/edx-platform-ft,Stanford-Online/edx-platform,jzoldak/edx-platform,Livit/Livit.Learn.EdX,UXE/local-edx,cyanna/edx-platform,hkawasaki/kawasaki-aio8-1,rationalAgent/edx-platform-custom,kalebhartje/schoolboost,wwj718/edx-platform,nikolas/edx-platform,RPI-OPENEDX/edx-platform,kamalx/edx-platform,IONISx/edx-platform,jruiperezv/ANALYSE,motion2015/edx-platform,eemirtekin/edx-platform,BehavioralInsightsTeam/edx-platform,devs1991/test_edx_docmode,EDUlib/edx-platform,solashirai/edx-platform,nttks/jenkins-test,zubair-arbi/edx-platform,nanolearning/edx-platform,beni55/edx-platform,xuxiao19910803/edx,Endika/edx-platform,zofuthan/edx-platform,polimediaupv/edx-platform,gymnasium/edx-platform,louyihua/edx-platform,kmoocdev/edx-platform,antonve/s4-project-mooc,ferabra/edx-platform,angelapper/edx-platform,J861449197/edx-platform,pomegranited/edx-platform,vismartltd/edx-platform,kalebhartje/schoolboost,sameetb-cuelogic/edx-platform-test,jzoldak/edx-platform,knehez/edx-platform,kmoocdev2/edx-platform,fintech-circle/edx-platform,praveen-pal/edx-platform,zerobatu/edx-platform,jruiperezv/ANALYSE,jamesblunt/edx-platform,doganov/edx-platform,zofuthan/edx-platform,martynovp/edx-platform,raccoongang/edx-platform,shurihell/testasia,appsembler/edx-platform,DefyVentures/edx-platform,chand3040/cloud_that,morpheby/levelup-by,teltek/edx-platform,ampax/edx-platform-backup,eduNEXT/edunext-platform,JCBarahona/edX,solashirai/edx-platform,kamalx/edx-platform,antonve/s4-project-mooc,nanolearningllc/edx-platform-cypress,Lektorium-LLC/edx-platform,SravanthiSinha/edx-platform,jazkarta/edx-platform-for-isc,waheedahmed/edx-platform,tiagochiavericosta/edx-platform,longmen21/edx-platform,xuxiao19910803/edx,solashirai/edx-platform,dsajkl/123,nttks/edx-platform,pepeportela/edx-platform,AkA84/edx-platform,chrisndodge/edx-platform,halvertoluke/edx-platform,Semi-global/edx-platform,eduNEXT/edunext-platform,mahendra-r/edx-platform,jamesblunt/edx-platform,UOMx/edx-platform,gsehub/edx-platform,JioEducation/edx-platform,jolyonb/edx-platform,jazkarta/edx-platform,zofuthan/edx-platform,chauhanhardik/populo,benpatterson/edx-platform,jswope00/griffinx,kamalx/edx-platform,alexthered/kienhoc-platform,ahmedaljazzar/edx-platform,shubhdev/edx-platform,sudheerchintala/LearnEraPlatForm,chrisndodge/edx-platform,deepsrijit1105/edx-platform,B-MOOC/edx-platform,pabloborrego93/edx-platform,DefyVentures/edx-platform,wwj718/ANALYSE,ubc/edx-platform,valtech-mooc/edx-platform,jazkarta/edx-platform,shubhdev/edxOnBaadal,TeachAtTUM/edx-platform,EDUlib/edx-platform,dsajkl/reqiop,benpatterson/edx-platform,adoosii/edx-platform,hkawasaki/kawasaki-aio8-2,fintech-circle/edx-platform,gymnasium/edx-platform,xingyepei/edx-platform,10clouds/edx-platform,ampax/edx-platform-backup,MSOpenTech/edx-platform,vismartltd/edx-platform,Edraak/edx-platform,fintech-circle/edx-platform,jonathan-beard/edx-platform,mjg2203/edx-platform-seas,jbassen/edx-platform,atsolakid/edx-platform,jonathan-beard/edx-platform,jamiefolsom/edx-platform,pdehaye/theming-edx-platform,nagyistoce/edx-platform,PepperPD/edx-pepper-platform,edx-solutions/edx-platform,ubc/edx-platform,shubhdev/edx-platform,LICEF/edx-platform,vismartltd/edx-platform,MakeHer/edx-platform,naresh21/synergetics-edx-platform,pku9104038/edx-platform,IndonesiaX/edx-platform,fly19890211/edx-platform,fly19890211/edx-platform,ESOedX/edx-platform,motion2015/edx-platform,tiagochiavericosta/edx-platform,motion2015/a3,doismellburning/edx-platform,DNFcode/edx-platform,EduPepperPDTesting/pepper2013-testing,Ayub-Khan/edx-platform,MakeHer/edx-platform,lduarte1991/edx-platform,B-MOOC/edx-platform,mcgachey/edx-platform,cpennington/edx-platform,motion2015/edx-platform,appliedx/edx-platform,andyzsf/edx,arifsetiawan/edx-platform,valtech-mooc/edx-platform,antoviaque/edx-platform,playm2mboy/edx-platform,apigee/edx-platform,zerobatu/edx-platform,jswope00/griffinx,y12uc231/edx-platform,yokose-ks/edx-platform,appliedx/edx-platform,beacloudgenius/edx-platform,Edraak/edx-platform,cselis86/edx-platform,amir-qayyum-khan/edx-platform,cognitiveclass/edx-platform,ubc/edx-platform,LearnEra/LearnEraPlaftform,playm2mboy/edx-platform,jazztpt/edx-platform,y12uc231/edx-platform,teltek/edx-platform,RPI-OPENEDX/edx-platform,abdoosh00/edx-rtl-final,nttks/jenkins-test,ahmadiga/min_edx,kursitet/edx-platform,zadgroup/edx-platform,zerobatu/edx-platform,4eek/edx-platform,playm2mboy/edx-platform,leansoft/edx-platform,rue89-tech/edx-platform,SravanthiSinha/edx-platform,ferabra/edx-platform,PepperPD/edx-pepper-platform,morenopc/edx-platform,doganov/edx-platform,ahmadio/edx-platform,caesar2164/edx-platform,EduPepperPD/pepper2013,eestay/edx-platform,pomegranited/edx-platform,hastexo/edx-platform,IITBinterns13/edx-platform-dev,cecep-edu/edx-platform,appsembler/edx-platform,SivilTaram/edx-platform,motion2015/a3,Ayub-Khan/edx-platform,appliedx/edx-platform,DNFcode/edx-platform,nikolas/edx-platform,pku9104038/edx-platform,rationalAgent/edx-platform-custom,zhenzhai/edx-platform,knehez/edx-platform,franosincic/edx-platform,longmen21/edx-platform,ESOedX/edx-platform,EduPepperPDTesting/pepper2013-testing,pomegranited/edx-platform,beacloudgenius/edx-platform,mbareta/edx-platform-ft,benpatterson/edx-platform,rhndg/openedx,nanolearning/edx-platform,eestay/edx-platform,shubhdev/openedx,UOMx/edx-platform,polimediaupv/edx-platform,ak2703/edx-platform,antoviaque/edx-platform,RPI-OPENEDX/edx-platform,abdoosh00/edx-rtl-final,cognitiveclass/edx-platform,chand3040/cloud_that,valtech-mooc/edx-platform,bitifirefly/edx-platform,kursitet/edx-platform,alu042/edx-platform,IITBinterns13/edx-platform-dev,hamzehd/edx-platform,longmen21/edx-platform,shabab12/edx-platform,DNFcode/edx-platform,ahmadiga/min_edx,WatanabeYasumasa/edx-platform,philanthropy-u/edx-platform,carsongee/edx-platform,jswope00/GAI,edry/edx-platform,martynovp/edx-platform,dcosentino/edx-platform,IndonesiaX/edx-platform,eemirtekin/edx-platform,mahendra-r/edx-platform,angelapper/edx-platform,stvstnfrd/edx-platform,edry/edx-platform,MSOpenTech/edx-platform,jruiperezv/ANALYSE,xuxiao19910803/edx-platform,mtlchun/edx,ahmadio/edx-platform,shubhdev/edx-platform,nagyistoce/edx-platform,xingyepei/edx-platform,mjirayu/sit_academy,shubhdev/openedx,waheedahmed/edx-platform,angelapper/edx-platform,shurihell/testasia,caesar2164/edx-platform,synergeticsedx/deployment-wipro,jbassen/edx-platform,iivic/BoiseStateX,vikas1885/test1,kalebhartje/schoolboost,Shrhawk/edx-platform,pku9104038/edx-platform,andyzsf/edx,romain-li/edx-platform,kxliugang/edx-platform,jolyonb/edx-platform,Kalyzee/edx-platform,Shrhawk/edx-platform,OmarIthawi/edx-platform,pabloborrego93/edx-platform,openfun/edx-platform,atsolakid/edx-platform,auferack08/edx-platform,jazkarta/edx-platform-for-isc,leansoft/edx-platform,ubc/edx-platform,jonathan-beard/edx-platform,nanolearningllc/edx-platform-cypress,chudaol/edx-platform,jbassen/edx-platform,alexthered/kienhoc-platform,shashank971/edx-platform,jbassen/edx-platform,chrisndodge/edx-platform,LearnEra/LearnEraPlaftform,pepeportela/edx-platform,arifsetiawan/edx-platform,bigdatauniversity/edx-platform,devs1991/test_edx_docmode,vismartltd/edx-platform,hmcmooc/muddx-platform,bdero/edx-platform,a-parhom/edx-platform,andyzsf/edx,B-MOOC/edx-platform,marcore/edx-platform,martynovp/edx-platform,utecuy/edx-platform,louyihua/edx-platform,SravanthiSinha/edx-platform,edx/edx-platform,Edraak/circleci-edx-platform,Semi-global/edx-platform,wwj718/ANALYSE,rue89-tech/edx-platform,romain-li/edx-platform,rismalrv/edx-platform,jjmiranda/edx-platform,kxliugang/edx-platform,jazkarta/edx-platform-for-isc,utecuy/edx-platform,zerobatu/edx-platform,ZLLab-Mooc/edx-platform,Kalyzee/edx-platform,EDUlib/edx-platform,chudaol/edx-platform,miptliot/edx-platform,kmoocdev/edx-platform | lms/djangoapps/courseware/features/video.py | lms/djangoapps/courseware/features/video.py | #pylint: disable=C0111
from lettuce import world, step
from common import *
############### ACTIONS ####################
@step('when I view it it does autoplay')
def does_autoplay(step):
assert(world.css_find('.video')[0]['data-autoplay'] == 'True')
@step('the course has a Video component')
def view_video(step):
coursename = TEST_COURSE_NAME.replace(' ', '_')
i_am_registered_for_the_course(step, coursename)
# Make sure we have a video
video = add_video_to_course(coursename)
chapter_name = TEST_SECTION_NAME.replace(" ", "_")
section_name = chapter_name
url = django_url('/courses/edx/Test_Course/Test_Course/courseware/%s/%s' %
(chapter_name, section_name))
world.browser.visit(url)
def add_video_to_course(course):
template_name = 'i4x://edx/templates/video/default'
world.ItemFactory.create(parent_location=section_location(course),
template=template_name,
display_name='Video')
| #pylint: disable=C0111
from lettuce import world, step
from common import *
############### ACTIONS ####################
@step('when I view it it does autoplay')
def does_autoplay(step):
assert(world.css_find('.video')[0]['data-autoplay'] == 'True')
@step('the course has a Video component')
def view_video(step):
coursename = TEST_COURSE_NAME.replace(' ', '_')
i_am_registered_for_the_course(step, coursename)
# Make sure we have a video
video = add_video_to_course(coursename)
chapter_name = TEST_SECTION_NAME.replace(" ", "_")
section_name = chapter_name
url = django_url('/courses/edx/Test_Course/Test_Course/courseware/%s/%s' %
(chapter_name, section_name))
world.browser.visit(url)
def add_video_to_course(course):
template_name = 'i4x://edx/templates/video/default'
world.ItemFactory.create(parent_location=section_location(course),
template=template_name,
display_name='Video')
| agpl-3.0 | Python |
54b0feebb18816a936f4a7f323a77808f9973eb2 | Update testes.py | kauaramirez/devops-aula05 | Src/testes.py | Src/testes.py | import jogovelha
import sys
erroInicializar = False
jogo = jogovelha.inicializar()
if len(jogo) != 3:
erroInicializar = True
else:
for linha in jogo:
if len(linha) != 3:
erroInicializar = True
else:
for elemento in linha:
if elemento != "X":
erroInicializar = True
if erroInicializar:
sys.exit(1)
else:
sys.exit(0)
| import jogovelha
import sys
erroInicializar = False
jogo = jogovelha.inicializar()
if len(jogo) != 3:
erroInicializar = True
else:
for linha in jogo:
if len(linha) != 3:
erroInicializar = True
else:
for elemento in linha:
if elemento != ".":
erroInicializar = True
if erroInicializar:
sys.exit(1)
else:
sys.exit(0) | apache-2.0 | Python |
73ceff96b2f065517a7d67cb0b25361f5bd61388 | Delete fixture after running tests | cpsaltis/pythogram-core | src/gramcore/filters/tests/test_edges.py | src/gramcore/filters/tests/test_edges.py | """Tests for module gramcore.filters.edges"""
import os
import numpy
from PIL import Image, ImageDraw
from nose.tools import assert_equal
from skimage import io
from gramcore.filters import edges
def setup():
"""Create image fixture
The background color is set by default to black (value == 0).
.. note::
Although the rectangle should be 10x10 in reality it returns an 11x11.
If the image is read with io.imread, then the colored pixels and their
neighbours can be accessed with arr[9:22, 4:17].
"""
img = Image.new('L', (20, 40))
draw = ImageDraw.Draw(img)
draw.rectangle([(5, 10), (15, 20)], fill=255)
img.save('white-square.tif')
del draw
def teardown():
"""Delete fixture"""
os.remove('white-square.tif')
def test_canny():
"""Apply canny to grey image and check return values
.. warning::
This seems to produce some artifacts. The fixture is a black
image with a white 11x11 rectangle. Thus you expect you get 44 (4*11)
pixels of edges. Instead it gets 50, when sigma is 1 and 40 when sigma
is 2. In both cases the shape is not correct.
"""
img = io.imread('white-square.tif')
parameters = {'data': [img], 'sigma': 1.0}
result = edges.canny(parameters)
# this should be 44 check the resulting image with
#result *= 255
#io.imsave('result.tif', result)
assert_equal(result.sum(), 50)
def test_prewitt():
"""Apply prewitt to grey image and check return values
.. note::
This produces correct shape though it shrinks it by 2 pixels, there
are no edge pixels on the corners and each edge has a width of 2
pixels. Based on the original rectangle size, which is 11x11, and the
above issues it returns 4*9*2 = 72 edge pixels.
"""
img = io.imread('white-square.tif')
parameters = {'data': [img]}
result = edges.prewitt(parameters)
result = result.astype('uint8')
assert_equal(result.sum(), 72)
def test_sobel():
"""Apply sobel to grey image and check return values
.. note::
This produces correct shape though it shrinks it by 2 pixels and each
edge has a width of 2 pixels. Based on the original rectangle size,
which is 11x11, and the above issues it returns 4*9*2 + 4 = 76 edge
pixels.
"""
img = io.imread('white-square.tif')
parameters = {'data': [img]}
result = edges.sobel(parameters)
result = result.astype('uint8')
assert_equal(result.sum(), 76)
| """Tests for module gramcore.filters.edges"""
import os
import numpy
from PIL import Image, ImageDraw
from nose.tools import assert_equal
from skimage import io
from gramcore.filters import edges
def setup():
"""Create image fixture
The background color is set by default to black (value == 0).
.. note::
Although the rectangle should be 10x10 in reality it returns an 11x11.
If the image is read with io.imread, then the colored pixels and their
neighbours can be accessed with arr[9:22, 4:17].
"""
img = Image.new('L', (20, 40))
draw = ImageDraw.Draw(img)
draw.rectangle([(5, 10), (15, 20)], fill=255)
img.save('white-square.tif')
del draw
def teardown():
"""Delete fixture"""
#os.remove('white-square.tif')
def test_canny():
"""Apply canny to grey image and check return values
.. warning::
This seems to produce some artifacts. The fixture is a black
image with a white 11x11 rectangle. Thus you expect you get 44 (4*11)
pixels of edges. Instead it gets 50, when sigma is 1 and 40 when sigma
is 2. In both cases the shape is not correct.
"""
img = io.imread('white-square.tif')
parameters = {'data': [img], 'sigma': 1.0}
result = edges.canny(parameters)
# this should be 44 check the resulting image with
#result *= 255
#io.imsave('result.tif', result)
assert_equal(result.sum(), 50)
def test_prewitt():
"""Apply prewitt to grey image and check return values
.. note::
This produces correct shape though it shrinks it by 2 pixels, there
are no edge pixels on the corners and each edge has a width of 2
pixels. Based on the original rectangle size, which is 11x11, and the
above issues it returns 4*9*2 = 72 edge pixels.
"""
img = io.imread('white-square.tif')
parameters = {'data': [img]}
result = edges.prewitt(parameters)
result = result.astype('uint8')
assert_equal(result.sum(), 72)
def test_sobel():
"""Apply sobel to grey image and check return values
.. note::
This produces correct shape though it shrinks it by 2 pixels and each
edge has a width of 2 pixels. Based on the original rectangle size,
which is 11x11, and the above issues it returns 4*9*2 + 4 = 76 edge
pixels.
"""
img = io.imread('white-square.tif')
parameters = {'data': [img]}
result = edges.sobel(parameters)
result = result.astype('uint8')
assert_equal(result.sum(), 76)
| mit | Python |
bd8caf6ab48bb1fbefdced7f33edabbdf017894a | Change of names | sk-/python2.7-type-annotator,sk-/python2.7-type-annotator,sk-/python2.7-type-annotator | Demo/sockets/echosvr.py | Demo/sockets/echosvr.py | #! /usr/local/python
# Python implementation of an 'echo' tcp server: echo all data it receives.
#
# This is the simplest possible server, sevicing a single request only.
import sys
from socket import *
# The standard echo port isn't very useful, it requires root permissions!
# ECHO_PORT = 7
ECHO_PORT = 50000 + 7
BUFSIZE = 1024
def main():
if len(sys.argv) > 1:
port = int(eval(sys.argv[1]))
else:
port = ECHO_PORT
s = socket(AF_INET, SOCK_STREAM)
s.bind('', port)
s.listen(0)
conn, (remotehost, remoteport) = s.accept()
print 'connected by', remotehost, remoteport
while 1:
data = conn.recv(BUFSIZE)
if not data:
break
conn.send(data)
main()
| #! /usr/local/python
# Python implementation of an 'echo' tcp server: echo all data it receives.
#
# This is the simplest possible server, sevicing a single request only.
import sys
from socket import *
# The standard echo port isn't very useful, it requires root permissions!
# ECHO_PORT = 7
ECHO_PORT = 50000 + 7
BUFSIZE = 1024
def main():
if len(sys.argv) > 1:
port = int(eval(sys.argv[1]))
else:
port = ECHO_PORT
s = socket(AF_INET, SOCK_STREAM)
s.bind('', port)
s.listen(0)
conn, (host, remoteport) = s.accept()
print 'connected by', host, remoteport
while 1:
data = conn.recv(BUFSIZE)
if not data:
break
conn.send(data)
main()
| mit | Python |
dac5de12f9e775d50bb1e441016ae9625052e149 | expand ALLOWED_HOSTS | uktrade/navigator,uktrade/navigator,uktrade/navigator,uktrade/navigator | app/navigator/settings/prod.py | app/navigator/settings/prod.py | from .base import *
DEBUG = False
# As the app is running behind a host-based router supplied by Heroku or other
# PaaS, we can open ALLOWED_HOSTS
ALLOWED_HOSTS = ['*']
INSTALLED_APPS += [
'raven.contrib.django.raven_compat'
]
SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 31536000
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
# Activity Stream API
ACTIVITY_STREAM_ACCESS_KEY_ID = env.str('ACTIVITY_STREAM_ACCESS_KEY_ID')
ACTIVITY_STREAM_SECRET_ACCESS_KEY = env.str('ACTIVITY_STREAM_SECRET_ACCESS_KEY')
| from .base import *
DEBUG = False
ALLOWED_HOSTS = [
'selling-online-overseas.export.great.gov.uk',
'navigator.cloudapps.digital',
'navigator.london.cloudapps.digital',
'www.great.gov.uk']
INSTALLED_APPS += [
'raven.contrib.django.raven_compat'
]
SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 31536000
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
# Activity Stream API
ACTIVITY_STREAM_ACCESS_KEY_ID = env.str('ACTIVITY_STREAM_ACCESS_KEY_ID')
ACTIVITY_STREAM_SECRET_ACCESS_KEY = env.str('ACTIVITY_STREAM_SECRET_ACCESS_KEY')
| mit | Python |
64804965e031f365937ef8fe70dc749c4532053d | fix abstract scraper, can't use lxml's url parsing because we need a custom user agent | texastribune/the-dp,texastribune/the-dp,texastribune/the-dp,texastribune/the-dp | tx_highered/scripts/initial_wikipedia.py | tx_highered/scripts/initial_wikipedia.py | #! /usr/bin/env python
try:
from django.utils.timezone import now
except ImportError:
from datetime.datetime import now
import requests
from lxml.html import document_fromstring, tostring
from tx_highered.models import Institution
def get_wiki_title(name):
endpoint = "http://en.wikipedia.org/w/api.php"
params = dict(action="opensearch",
search=name,
limit=1,
namespace=0,
format="json",)
r = requests.get(endpoint, params=params)
try:
_, results = r.json
title = results[0]
except IndexError:
return None
return title
def get_wiki_abstract(url):
r = requests.get(url, headers={'User-Agent': 'thedp-scraper/0.1alpha'})
doc = document_fromstring(r.text)
root = doc
try:
toc = root.get_element_by_id('toc')
except KeyError:
return None
abstract = []
for elem in toc.getparent().iterchildren():
if elem == toc:
break
if elem.tag == 'p':
elem.make_links_absolute(url)
abstract.append(tostring(elem))
return "\n".join(abstract).strip()
def main():
queryset = Institution.objects.filter(institution_type='uni')
qs = queryset.filter(wikipedia_title__isnull=True)
for inst in qs:
title = get_wiki_title(inst.name)
if title:
inst.wikipedia_title = title
inst.save()
print inst.name + " -> " + title
qs = queryset.filter(wikipedia_title__isnull=False, wikipedia_scraped=None)
for inst in qs:
text = get_wiki_abstract(inst.wikipedia_url)
if text:
inst.wikipedia_abstract = text
inst.wikipedia_scraped = now()
inst.save()
print inst
if __name__ == "__main__":
main()
| #! /usr/bin/env python
import datetime
import requests
from lxml.html import parse, tostring
from tx_highered.models import Institution
def get_wiki_title(name):
endpoint = "http://en.wikipedia.org/w/api.php"
params = dict(action="opensearch",
search=name,
limit=1,
namespace=0,
format="json",)
r = requests.get(endpoint, params=params)
try:
_, results = r.json
title = results[0]
except IndexError:
return None
return title
def get_wiki_abstract(url):
doc = parse(url) # won't handle https
root = doc.getroot()
toc = root.get_element_by_id('toc')
abstract = []
for elem in toc.getparent().iterchildren():
if elem == toc:
break
if elem.tag == 'p':
elem.make_links_absolute()
abstract.append(tostring(elem))
return "\n".join(abstract).strip()
def main():
queryset = Institution.objects.filter(institution_type='uni')
qs = queryset.filter(wikipedia_title__isnull=True)
for inst in qs:
title = get_wiki_title(inst.name)
if title:
inst.wikipedia_title = title
inst.save()
print inst.name + " -> " + title
qs = queryset.filter(wikipedia_title__isnull=False, wikipedia_scraped=None)
for inst in qs:
text = get_wiki_abstract(inst.wikipedia_url)
if text:
inst.wikipedia_abstract = text
inst.wikipedia_scraped = datetime.datetime.now()
inst.save()
print inst
if __name__ == "__main__":
main()
| apache-2.0 | Python |
db3f71f537a85396d777ba28d3ad6c8156137c24 | Change pg key | juruen/cavalieri,juruen/cavalieri,juruen/cavalieri,juruen/cavalieri | src/python/pagerduty.py | src/python/pagerduty.py | import json
import urllib2
PD_URL = "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
TIMEOUT = 10
def request(action, json_str):
obj = json.loads(json_str)
description = "%s %s is %s ( %s )" % (
obj.get('host', 'unknown host'),
obj.get('service', 'unknown service'),
obj.get('state', 'unknown state'),
obj.get('metric', 'nil'))
pg_key = obj.pop('pg_key')
event = {
'service_key': pg_key,
'event_type': action,
'incident_key': "%s %s" % (obj['host'], obj['service']),
'description': description,
'details': json.dumps(obj)
}
try:
result = json.loads(
urllib2.urlopen(PD_URL, json.dumps(event), TIMEOUT).read())
print result
except Exception, e:
print str(e)
return False
return result['status'] == 'success'
def trigger(json_str):
return request('trigger', json_str)
def acknowledge(json_str):
return request('acknowledge', json_str)
def resolve(json_str):
return request('resolve', json_str)
args = {
'pg_key': 'fixme',
'description': 'this is a test',
'host': 'foobar.com',
'service': 'whatever'
}
#trigger(json.dumps(args))
#resolve(json.dumps(args))
| import json
import urllib2
PD_URL = "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
TIMEOUT = 10
def request(action, json_str):
obj = json.loads(json_str)
description = "%s %s is %s ( %s )" % (
obj.get('host', 'unknown host'),
obj.get('service', 'unknown service'),
obj.get('state', 'unknown state'),
obj.get('metric', 'nil'))
pg_key = obj.pop('pg_key')
event = {
'service_key': pg_key,
'event_type': action,
'incident_key': "%s %s" % (obj['host'], obj['service']),
'description': description,
'details': json.dumps(obj)
}
try:
result = json.loads(
urllib2.urlopen(PD_URL, json.dumps(event), TIMEOUT).read())
print result
except Exception, e:
print str(e)
return False
return result['status'] == 'success'
def trigger(json_str):
return request('trigger', json_str)
def acknowledge(json_str):
return request('acknowledge', json_str)
def resolve(json_str):
return request('resolve', json_str)
args = {
'pg_key': '113852fbf4d34663b87b7321e9eba1e1',
'description': 'this is a test',
'host': 'foobar.com',
'service': 'whatever'
}
#trigger(json.dumps(args))
#resolve(json.dumps(args))
| mit | Python |
3999e9812a766066dcccf6a4d07174144cb9f72d | Add Minecraft Wiki link to version item | wurstmineberg/bitbar-server-status | wurstmineberg.45s.py | wurstmineberg.45s.py | #!/usr/local/bin/python3
import requests
people = requests.get('https://api.wurstmineberg.de/v2/people.json').json()
status = requests.get('https://api.wurstmineberg.de/v2/world/wurstmineberg/status.json').json()
print(len(status['list']))
print('---')
print('Version: {ver}|href=http://minecraft.gamepedia.com/{ver} color=gray'.format(ver=status['version']))
for wmb_id in status['list']:
display_name = people['people'].get(wmb_id, {}).get('name', wmb_id)
if people['people'].get(wmb_id, False) and people['people'][wmb_id].get('slack', False):
slack_name = people['people'][wmb_id]['slack']['username']
slack_url = 'https://wurstmineberg.slack.com/messages/@' + slack_name
else:
slack_url = None
print('{}|href=https://wurstmineberg.de/people/{} color=#2889be'.format(display_name, wmb_id))
if slack_url is not None:
print('@{}|alternate=true href={} color=red'.format(slack_name, slack_url))
print('---')
print('Start Minecraft | bash=/usr/bin/open param1=-a param2=Minecraft terminal=false')
| #!/usr/local/bin/python3
import requests
people = requests.get('https://api.wurstmineberg.de/v2/people.json').json()
status = requests.get('https://api.wurstmineberg.de/v2/world/wurstmineberg/status.json').json()
print(len(status['list']))
print('---')
print('Version: {}|color=gray'.format(status['version']))
for wmb_id in status['list']:
display_name = people['people'].get(wmb_id, {}).get('name', wmb_id)
if people['people'].get(wmb_id, False) and people['people'][wmb_id].get('slack', False):
slack_name = people['people'][wmb_id]['slack']['username']
slack_url = 'https://wurstmineberg.slack.com/messages/@' + slack_name
else:
slack_url = None
print('{}|href=https://wurstmineberg.de/people/{} color=#2889be'.format(display_name, wmb_id))
if slack_url is not None:
print('@{}|alternate=true href={} color=red'.format(slack_name, slack_url))
print('---')
print('Start Minecraft | bash=/usr/bin/open param1=-a param2=Minecraft terminal=false')
| mit | Python |
d792201bc311a15e5df48259008331b771c59aca | Fix CSS problem when Flexx is enbedded in page-app | jrversteegh/flexx,JohnLunzer/flexx,zoofIO/flexx,JohnLunzer/flexx,jrversteegh/flexx,JohnLunzer/flexx,zoofIO/flexx | flexx/ui/layouts/_layout.py | flexx/ui/layouts/_layout.py | """ Layout widgets
"""
from . import Widget
class Layout(Widget):
""" Abstract class for widgets that organize their child widgets.
Panel widgets are layouts that do not take the natural size of their
content into account, making them more efficient and suited for
high-level layout. Other layouts, like HBox, are more suited for
laying out content where the natural size is important.
"""
CSS = """
body {
margin: 0;
padding: 0;
/*overflow: hidden;*/
}
.flx-Layout {
/* sizing of widgets/layouts inside layout is defined per layout */
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
border-spacing: 0px;
border: 0px;
}
"""
| """ Layout widgets
"""
from . import Widget
class Layout(Widget):
""" Abstract class for widgets that organize their child widgets.
Panel widgets are layouts that do not take the natural size of their
content into account, making them more efficient and suited for
high-level layout. Other layouts, like HBox, are more suited for
laying out content where the natural size is important.
"""
CSS = """
body {
margin: 0;
padding: 0;
overflow: hidden;
}
.flx-Layout {
/* sizing of widgets/layouts inside layout is defined per layout */
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
border-spacing: 0px;
border: 0px;
}
"""
| bsd-2-clause | Python |
a9cfdf8fdb6853f175cdc31abc2dec91ec6dcf3a | fix import | SchrodingersGat/InvenTree,inventree/InvenTree,SchrodingersGat/InvenTree,inventree/InvenTree,inventree/InvenTree,SchrodingersGat/InvenTree,SchrodingersGat/InvenTree,inventree/InvenTree | InvenTree/part/tasks.py | InvenTree/part/tasks.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import logging
from django.utils.translation import gettext_lazy as _
import InvenTree.helpers
import InvenTree.tasks
import common.notifications
import part.models
logger = logging.getLogger("inventree")
def notify_low_stock(part: part.models.Part):
name = _("Low stock notification")
message = _(f'The available stock for {part.name} has fallen below the configured minimum level')
context = {
'part': part,
'name': name,
'message': message,
'link': InvenTree.helpers.construct_absolute_url(part.get_absolute_url()),
'template': {
'html': 'email/low_stock_notification.html',
'subject': "[InvenTree] " + name,
},
}
common.notifications.trigger_notifaction(
part,
'part.notify_low_stock',
target_fnc=part.get_subscribers,
context=context,
)
def notify_low_stock_if_required(part: part.models.Part):
"""
Check if the stock quantity has fallen below the minimum threshold of part.
If true, notify the users who have subscribed to the part
"""
# Run "up" the tree, to allow notification for "parent" parts
parts = part.get_ancestors(include_self=True, ascending=True)
for p in parts:
if p.is_part_low_on_stock():
InvenTree.tasks.offload_task(
notify_low_stock,
p
)
| # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import logging
from django.utils.translation import gettext_lazy as _
import InvenTree.helpers
import InvenTree.tasks
import common.notifications
import part.models
from part import tasks as part_tasks
logger = logging.getLogger("inventree")
def notify_low_stock(part: part.models.Part):
name = _("Low stock notification")
message = _(f'The available stock for {part.name} has fallen below the configured minimum level')
context = {
'part': part,
'name': name,
'message': message,
'link': InvenTree.helpers.construct_absolute_url(part.get_absolute_url()),
'template': {
'html': 'email/low_stock_notification.html',
'subject': "[InvenTree] " + name,
},
}
common.notifications.trigger_notifaction(
part,
'part.notify_low_stock',
target_fnc=part.get_subscribers,
context=context,
)
def notify_low_stock_if_required(part: part.models.Part):
"""
Check if the stock quantity has fallen below the minimum threshold of part.
If true, notify the users who have subscribed to the part
"""
# Run "up" the tree, to allow notification for "parent" parts
parts = part.get_ancestors(include_self=True, ascending=True)
for p in parts:
if p.is_part_low_on_stock():
InvenTree.tasks.offload_task(
part_tasks.notify_low_stock,
p
)
| mit | Python |
26a21a9f5da718852c193420a0132ad822139ec0 | Remove PHPBB crap | ronakkhunt/kuma,hoosteeno/kuma,surajssd/kuma,ollie314/kuma,chirilo/kuma,ronakkhunt/kuma,Elchi3/kuma,bluemini/kuma,safwanrahman/kuma,davehunt/kuma,scrollback/kuma,safwanrahman/kuma,groovecoder/kuma,hoosteeno/kuma,cindyyu/kuma,MenZil/kuma,anaran/kuma,robhudson/kuma,darkwing/kuma,mozilla/kuma,utkbansal/kuma,SphinxKnight/kuma,cindyyu/kuma,groovecoder/kuma,chirilo/kuma,scrollback/kuma,a2sheppy/kuma,MenZil/kuma,darkwing/kuma,tximikel/kuma,RanadeepPolavarapu/kuma,davidyezsetz/kuma,utkbansal/kuma,MenZil/kuma,RanadeepPolavarapu/kuma,a2sheppy/kuma,safwanrahman/kuma,tximikel/kuma,FrankBian/kuma,ollie314/kuma,varunkamra/kuma,darkwing/kuma,cindyyu/kuma,YOTOV-LIMITED/kuma,utkbansal/kuma,varunkamra/kuma,hoosteeno/kuma,jwhitlock/kuma,tximikel/kuma,carnell69/kuma,carnell69/kuma,darkwing/kuma,chirilo/kuma,yfdyh000/kuma,mastizada/kuma,yfdyh000/kuma,davehunt/kuma,ollie314/kuma,anaran/kuma,jgmize/kuma,MenZil/kuma,a2sheppy/kuma,bluemini/kuma,FrankBian/kuma,groovecoder/kuma,SphinxKnight/kuma,utkbansal/kuma,openjck/kuma,openjck/kuma,nhenezi/kuma,groovecoder/kuma,yfdyh000/kuma,RanadeepPolavarapu/kuma,surajssd/kuma,MenZil/kuma,bluemini/kuma,yfdyh000/kuma,mozilla/kuma,ronakkhunt/kuma,jezdez/kuma,chirilo/kuma,groovecoder/kuma,escattone/kuma,ronakkhunt/kuma,jezdez/kuma,robhudson/kuma,SphinxKnight/kuma,Elchi3/kuma,mastizada/kuma,cindyyu/kuma,tximikel/kuma,jezdez/kuma,carnell69/kuma,carnell69/kuma,hoosteeno/kuma,openjck/kuma,biswajitsahu/kuma,davehunt/kuma,whip112/Whip112,a2sheppy/kuma,biswajitsahu/kuma,nhenezi/kuma,jezdez/kuma,robhudson/kuma,jezdez/kuma,anaran/kuma,openjck/kuma,surajssd/kuma,Elchi3/kuma,whip112/Whip112,FrankBian/kuma,surajssd/kuma,FrankBian/kuma,whip112/Whip112,safwanrahman/kuma,davehunt/kuma,davidyezsetz/kuma,RanadeepPolavarapu/kuma,ollie314/kuma,robhudson/kuma,anaran/kuma,cindyyu/kuma,SphinxKnight/kuma,anaran/kuma,YOTOV-LIMITED/kuma,surajssd/kuma,jgmize/kuma,scrollback/kuma,biswajitsahu/kuma,whip112/Whip112,jwhitlock/kuma,nhenezi/kuma,jwhitlock/kuma,biswajitsahu/kuma,jgmize/kuma,groovecoder/kuma,varunkamra/kuma,escattone/kuma,safwanrahman/kuma,varunkamra/kuma,darkwing/kuma,jwhitlock/kuma,carnell69/kuma,biswajitsahu/kuma,mozilla/kuma,YOTOV-LIMITED/kuma,davidyezsetz/kuma,YOTOV-LIMITED/kuma,robhudson/kuma,safwanrahman/kuma,scrollback/kuma,whip112/Whip112,davehunt/kuma,ronakkhunt/kuma,davidyezsetz/kuma,davehunt/kuma,YOTOV-LIMITED/kuma,yfdyh000/kuma,FrankBian/kuma,Elchi3/kuma,Elchi3/kuma,YOTOV-LIMITED/kuma,robhudson/kuma,RanadeepPolavarapu/kuma,mozilla/kuma,chirilo/kuma,darkwing/kuma,ronakkhunt/kuma,tximikel/kuma,bluemini/kuma,hoosteeno/kuma,jgmize/kuma,nhenezi/kuma,bluemini/kuma,utkbansal/kuma,hoosteeno/kuma,scrollback/kuma,chirilo/kuma,carnell69/kuma,ollie314/kuma,openjck/kuma,cindyyu/kuma,surajssd/kuma,tximikel/kuma,RanadeepPolavarapu/kuma,anaran/kuma,jwhitlock/kuma,ollie314/kuma,mastizada/kuma,openjck/kuma,whip112/Whip112,biswajitsahu/kuma,utkbansal/kuma,mozilla/kuma,SphinxKnight/kuma,jgmize/kuma,davidyezsetz/kuma,jgmize/kuma,SphinxKnight/kuma,mastizada/kuma,varunkamra/kuma,MenZil/kuma,jezdez/kuma,yfdyh000/kuma,a2sheppy/kuma,bluemini/kuma,escattone/kuma,varunkamra/kuma,nhenezi/kuma | apps/devmo/context_processors.py | apps/devmo/context_processors.py | from django.conf import settings
from django.utils import translation
def i18n(request):
return {'LANGUAGES': settings.LANGUAGES,
'LANG': settings.LANGUAGE_URL_MAP.get(translation.get_language())
or translation.get_language(),
'DIR': 'rtl' if translation.get_language_bidi() else 'ltr',
}
def next_url(request):
if 'login' not in request.path and 'register' not in request.path:
return {'next_url': request.path }
return {} | from django.conf import settings
from django.utils import translation
def i18n(request):
return {'LANGUAGES': settings.LANGUAGES,
'LANG': settings.LANGUAGE_URL_MAP.get(translation.get_language())
or translation.get_language(),
'DIR': 'rtl' if translation.get_language_bidi() else 'ltr',
}
def next_url(request):
if 'login' not in request.path and 'register' not in request.path:
return {'next_url': request.path }
return {}
def phpbb_logged_in(request):
"""Detect PHPBB login cookie."""
return {
'PHPBB_LOGGED_IN': (request.COOKIES.get(
'%s_u' % settings.PHPBB_COOKIE_PREFIX, '1') != '1'),
'PHPBB_SID': request.COOKIES.get(
'%s_sid' % settings.PHPBB_COOKIE_PREFIX),
}
| mpl-2.0 | Python |
2bf43e3ba86cc248e752175ffb82f4eab1803119 | delete question module had bug previously | unicefuganda/uSurvey,unicefuganda/uSurvey,unicefuganda/uSurvey,unicefuganda/uSurvey,unicefuganda/uSurvey | survey/models/question_module.py | survey/models/question_module.py | from survey.models import BaseModel
from django.db import models
class QuestionModule(BaseModel):
name = models.CharField(max_length=255)
description = models.TextField(null=True, blank=True)
def remove_related_questions(self):
self.question_templates.all().delete()
def __unicode__(self):
return self.name
| from survey.models import BaseModel
from django.db import models
class QuestionModule(BaseModel):
name = models.CharField(max_length=255)
description = models.TextField(null=True, blank=True)
def remove_related_questions(self):
self.question_templates.delete()
def __unicode__(self):
return self.name
| bsd-3-clause | Python |
e21e2ff9b8258be5533261f7834438c80b0082cc | Use iter(...) instead of .iter() | jeffreyliu3230/osf.io,hmoco/osf.io,jmcarp/osf.io,kwierman/osf.io,felliott/osf.io,pattisdr/osf.io,arpitar/osf.io,brianjgeiger/osf.io,mfraezz/osf.io,jinluyuan/osf.io,MerlinZhang/osf.io,caseyrollins/osf.io,RomanZWang/osf.io,brianjgeiger/osf.io,kch8qx/osf.io,acshi/osf.io,rdhyee/osf.io,haoyuchen1992/osf.io,cslzchen/osf.io,mluke93/osf.io,SSJohns/osf.io,jeffreyliu3230/osf.io,icereval/osf.io,ckc6cz/osf.io,jnayak1/osf.io,TomHeatwole/osf.io,wearpants/osf.io,laurenrevere/osf.io,chrisseto/osf.io,kwierman/osf.io,petermalcolm/osf.io,felliott/osf.io,sbt9uc/osf.io,njantrania/osf.io,asanfilippo7/osf.io,cosenal/osf.io,jnayak1/osf.io,reinaH/osf.io,dplorimer/osf,aaxelb/osf.io,haoyuchen1992/osf.io,adlius/osf.io,mluo613/osf.io,brandonPurvis/osf.io,jinluyuan/osf.io,jeffreyliu3230/osf.io,amyshi188/osf.io,binoculars/osf.io,cwisecarver/osf.io,billyhunt/osf.io,MerlinZhang/osf.io,reinaH/osf.io,erinspace/osf.io,kwierman/osf.io,lyndsysimon/osf.io,samchrisinger/osf.io,Johnetordoff/osf.io,samanehsan/osf.io,monikagrabowska/osf.io,mattclark/osf.io,reinaH/osf.io,arpitar/osf.io,danielneis/osf.io,SSJohns/osf.io,monikagrabowska/osf.io,samchrisinger/osf.io,mluo613/osf.io,Johnetordoff/osf.io,cldershem/osf.io,njantrania/osf.io,mluke93/osf.io,wearpants/osf.io,brandonPurvis/osf.io,lyndsysimon/osf.io,zamattiac/osf.io,fabianvf/osf.io,caneruguz/osf.io,sbt9uc/osf.io,caseyrygt/osf.io,HarryRybacki/osf.io,mattclark/osf.io,alexschiller/osf.io,KAsante95/osf.io,saradbowman/osf.io,SSJohns/osf.io,monikagrabowska/osf.io,hmoco/osf.io,TomBaxter/osf.io,brianjgeiger/osf.io,ckc6cz/osf.io,chrisseto/osf.io,adlius/osf.io,njantrania/osf.io,ZobairAlijan/osf.io,GageGaskins/osf.io,dplorimer/osf,jolene-esposito/osf.io,caseyrollins/osf.io,SSJohns/osf.io,ticklemepierce/osf.io,sloria/osf.io,billyhunt/osf.io,mfraezz/osf.io,zamattiac/osf.io,zachjanicki/osf.io,HarryRybacki/osf.io,mluke93/osf.io,acshi/osf.io,ZobairAlijan/osf.io,caneruguz/osf.io,caneruguz/osf.io,cslzchen/osf.io,brandonPurvis/osf.io,chennan47/osf.io,aaxelb/osf.io,alexschiller/osf.io,zachjanicki/osf.io,Nesiehr/osf.io,mluo613/osf.io,mluo613/osf.io,sbt9uc/osf.io,adlius/osf.io,abought/osf.io,amyshi188/osf.io,jinluyuan/osf.io,aaxelb/osf.io,CenterForOpenScience/osf.io,TomHeatwole/osf.io,cslzchen/osf.io,billyhunt/osf.io,cwisecarver/osf.io,caneruguz/osf.io,samchrisinger/osf.io,leb2dg/osf.io,TomHeatwole/osf.io,billyhunt/osf.io,haoyuchen1992/osf.io,kch8qx/osf.io,hmoco/osf.io,KAsante95/osf.io,adlius/osf.io,asanfilippo7/osf.io,emetsger/osf.io,monikagrabowska/osf.io,rdhyee/osf.io,cosenal/osf.io,acshi/osf.io,ckc6cz/osf.io,doublebits/osf.io,erinspace/osf.io,abought/osf.io,alexschiller/osf.io,jnayak1/osf.io,bdyetton/prettychart,mluke93/osf.io,HalcyonChimera/osf.io,Johnetordoff/osf.io,HalcyonChimera/osf.io,jmcarp/osf.io,doublebits/osf.io,kch8qx/osf.io,MerlinZhang/osf.io,cwisecarver/osf.io,TomBaxter/osf.io,asanfilippo7/osf.io,bdyetton/prettychart,cldershem/osf.io,DanielSBrown/osf.io,zamattiac/osf.io,fabianvf/osf.io,dplorimer/osf,ticklemepierce/osf.io,pattisdr/osf.io,CenterForOpenScience/osf.io,sloria/osf.io,jnayak1/osf.io,kch8qx/osf.io,chrisseto/osf.io,mattclark/osf.io,baylee-d/osf.io,amyshi188/osf.io,aaxelb/osf.io,crcresearch/osf.io,fabianvf/osf.io,CenterForOpenScience/osf.io,arpitar/osf.io,mfraezz/osf.io,RomanZWang/osf.io,jeffreyliu3230/osf.io,cwisecarver/osf.io,DanielSBrown/osf.io,doublebits/osf.io,emetsger/osf.io,hmoco/osf.io,kch8qx/osf.io,brianjgeiger/osf.io,kwierman/osf.io,ticklemepierce/osf.io,zachjanicki/osf.io,RomanZWang/osf.io,emetsger/osf.io,jinluyuan/osf.io,HarryRybacki/osf.io,leb2dg/osf.io,danielneis/osf.io,jolene-esposito/osf.io,saradbowman/osf.io,chennan47/osf.io,caseyrollins/osf.io,jmcarp/osf.io,zachjanicki/osf.io,leb2dg/osf.io,crcresearch/osf.io,petermalcolm/osf.io,lyndsysimon/osf.io,amyshi188/osf.io,ckc6cz/osf.io,Johnetordoff/osf.io,doublebits/osf.io,TomBaxter/osf.io,samanehsan/osf.io,felliott/osf.io,lyndsysimon/osf.io,ZobairAlijan/osf.io,pattisdr/osf.io,chennan47/osf.io,chrisseto/osf.io,dplorimer/osf,mfraezz/osf.io,GageGaskins/osf.io,cosenal/osf.io,samanehsan/osf.io,danielneis/osf.io,icereval/osf.io,sbt9uc/osf.io,rdhyee/osf.io,bdyetton/prettychart,KAsante95/osf.io,petermalcolm/osf.io,billyhunt/osf.io,cslzchen/osf.io,caseyrygt/osf.io,GageGaskins/osf.io,Ghalko/osf.io,emetsger/osf.io,HalcyonChimera/osf.io,baylee-d/osf.io,felliott/osf.io,crcresearch/osf.io,rdhyee/osf.io,brandonPurvis/osf.io,HarryRybacki/osf.io,njantrania/osf.io,fabianvf/osf.io,icereval/osf.io,jolene-esposito/osf.io,alexschiller/osf.io,Nesiehr/osf.io,jolene-esposito/osf.io,HalcyonChimera/osf.io,doublebits/osf.io,haoyuchen1992/osf.io,reinaH/osf.io,cldershem/osf.io,monikagrabowska/osf.io,DanielSBrown/osf.io,RomanZWang/osf.io,Nesiehr/osf.io,asanfilippo7/osf.io,binoculars/osf.io,Ghalko/osf.io,samchrisinger/osf.io,alexschiller/osf.io,danielneis/osf.io,cosenal/osf.io,acshi/osf.io,Nesiehr/osf.io,erinspace/osf.io,Ghalko/osf.io,wearpants/osf.io,petermalcolm/osf.io,acshi/osf.io,abought/osf.io,brandonPurvis/osf.io,GageGaskins/osf.io,wearpants/osf.io,arpitar/osf.io,mluo613/osf.io,ZobairAlijan/osf.io,jmcarp/osf.io,samanehsan/osf.io,bdyetton/prettychart,caseyrygt/osf.io,KAsante95/osf.io,TomHeatwole/osf.io,DanielSBrown/osf.io,baylee-d/osf.io,ticklemepierce/osf.io,sloria/osf.io,RomanZWang/osf.io,CenterForOpenScience/osf.io,zamattiac/osf.io,leb2dg/osf.io,KAsante95/osf.io,abought/osf.io,laurenrevere/osf.io,Ghalko/osf.io,laurenrevere/osf.io,MerlinZhang/osf.io,GageGaskins/osf.io,binoculars/osf.io,cldershem/osf.io,caseyrygt/osf.io | framework/tasks/handlers.py | framework/tasks/handlers.py | # -*- coding: utf-8 -*-
import logging
import functools
from flask import g
from celery import group
from website import settings
logger = logging.getLogger(__name__)
def celery_before_request():
g._celery_tasks = []
def celery_teardown_request(error=None):
if error is not None:
return
try:
tasks = g._celery_tasks
if tasks:
group(iter(tasks)).apply_async()
except AttributeError:
if not settings.DEBUG_MODE:
logger.error('Task queue not initialized')
def enqueue_task(signature):
"""If working in a request context, push task signature to ``g`` to run
after request is complete; else run signature immediately.
:param signature: Celery task signature
"""
try:
if signature not in g._celery_tasks:
g._celery_tasks.append(signature)
except RuntimeError:
signature()
def queued_task(task):
"""Decorator that adds the wrapped task to the queue on ``g`` if Celery is
enabled, else runs the task synchronously. Can only be applied to Celery
tasks; should be used for all tasks fired within a request context that
may write to the database to avoid race conditions.
"""
@functools.wraps(task)
def wrapped(*args, **kwargs):
if settings.USE_CELERY:
signature = task.si(*args, **kwargs)
enqueue_task(signature)
else:
task(*args, **kwargs)
return wrapped
handlers = {
'before_request': celery_before_request,
'teardown_request': celery_teardown_request,
}
| # -*- coding: utf-8 -*-
import logging
import functools
from flask import g
from celery import group
from website import settings
logger = logging.getLogger(__name__)
def celery_before_request():
g._celery_tasks = []
def celery_teardown_request(error=None):
if error is not None:
return
try:
tasks = g._celery_tasks
if tasks:
group(tasks.iter()).apply_async()
except AttributeError:
if not settings.DEBUG_MODE:
logger.error('Task queue not initialized')
def enqueue_task(signature):
"""If working in a request context, push task signature to ``g`` to run
after request is complete; else run signature immediately.
:param signature: Celery task signature
"""
try:
if signature not in g._celery_tasks:
g._celery_tasks.append(signature)
except RuntimeError:
signature()
def queued_task(task):
"""Decorator that adds the wrapped task to the queue on ``g`` if Celery is
enabled, else runs the task synchronously. Can only be applied to Celery
tasks; should be used for all tasks fired within a request context that
may write to the database to avoid race conditions.
"""
@functools.wraps(task)
def wrapped(*args, **kwargs):
if settings.USE_CELERY:
signature = task.si(*args, **kwargs)
enqueue_task(signature)
else:
task(*args, **kwargs)
return wrapped
handlers = {
'before_request': celery_before_request,
'teardown_request': celery_teardown_request,
}
| apache-2.0 | Python |
9e2f9b040d0dde3237daca1c483c8b2bf0170663 | Update Arch package to 2.7 | bowlofstew/packages,biicode/packages,biicode/packages,bowlofstew/packages | archlinux/archpack_settings.py | archlinux/archpack_settings.py | #
# Biicode Arch Linux package settings.
#
# Check PKGBUILD_template docs for those settings and
# what they mean.
#
def settings():
return { "version": "2.7",
"release_number": "1",
"arch_deps": ["cmake>=3.0.2",
"zlib",
"glibc",
"sqlite",
"wget",
"python2-pmw"
],
"debian_deps": ["zlib1g",
"libc-bin",
"libsqlite3-0",
"wget",
"lib32z1",
"python-tk"
]
}
if __name__ == '__main__':
print(settings())
| #
# Biicode Arch Linux package settings.
#
# Check PKGBUILD_template docs for those settings and
# what they mean.
#
def settings():
return { "version": "2.6.1",
"release_number": "1",
"arch_deps": ["cmake>=3.0.2",
"zlib",
"glibc",
"sqlite",
"wget",
"python2-pmw"
],
"debian_deps": ["zlib1g",
"libc-bin",
"libsqlite3-0",
"wget",
"lib32z1",
"python-tk"
]
}
if __name__ == '__main__':
print(settings())
| bsd-2-clause | Python |
ecd33e00eb5eb8ff58358e01a6d618262e8381a6 | Update upstream version of vo | larrybradley/astropy,MSeifert04/astropy,tbabej/astropy,dhomeier/astropy,tbabej/astropy,StuartLittlefair/astropy,mhvk/astropy,astropy/astropy,lpsinger/astropy,DougBurke/astropy,aleksandr-bakanov/astropy,StuartLittlefair/astropy,dhomeier/astropy,joergdietrich/astropy,MSeifert04/astropy,stargaser/astropy,pllim/astropy,StuartLittlefair/astropy,larrybradley/astropy,saimn/astropy,AustereCuriosity/astropy,DougBurke/astropy,StuartLittlefair/astropy,AustereCuriosity/astropy,aleksandr-bakanov/astropy,funbaker/astropy,stargaser/astropy,kelle/astropy,joergdietrich/astropy,joergdietrich/astropy,joergdietrich/astropy,AustereCuriosity/astropy,dhomeier/astropy,AustereCuriosity/astropy,mhvk/astropy,astropy/astropy,saimn/astropy,saimn/astropy,funbaker/astropy,bsipocz/astropy,dhomeier/astropy,saimn/astropy,aleksandr-bakanov/astropy,kelle/astropy,pllim/astropy,bsipocz/astropy,tbabej/astropy,lpsinger/astropy,bsipocz/astropy,DougBurke/astropy,MSeifert04/astropy,larrybradley/astropy,pllim/astropy,kelle/astropy,stargaser/astropy,pllim/astropy,astropy/astropy,larrybradley/astropy,bsipocz/astropy,kelle/astropy,aleksandr-bakanov/astropy,mhvk/astropy,funbaker/astropy,kelle/astropy,DougBurke/astropy,tbabej/astropy,joergdietrich/astropy,astropy/astropy,dhomeier/astropy,saimn/astropy,MSeifert04/astropy,tbabej/astropy,funbaker/astropy,astropy/astropy,stargaser/astropy,lpsinger/astropy,lpsinger/astropy,larrybradley/astropy,mhvk/astropy,pllim/astropy,StuartLittlefair/astropy,AustereCuriosity/astropy,lpsinger/astropy,mhvk/astropy | astropy/io/vo/setup_package.py | astropy/io/vo/setup_package.py | from distutils.core import Extension
from os.path import join
from astropy import setup_helpers
def get_extensions(build_type='release'):
VO_DIR = 'astropy/io/vo/src'
return [Extension(
"astropy.io.vo.tablewriter",
[join(VO_DIR, "tablewriter.c")],
include_dirs=[VO_DIR])]
def get_package_data():
return {
'astropy.io.vo': [
'data/ucd1p-words.txt', 'data/*.xsd', 'data/*.dtd'],
'astropy.io.vo.tests': [
'data/*.xml', 'data/*.gz', 'data/*.json', 'data/*.fits',
'data/*.txt'],
'astropy.io.vo.validator': [
'urls/*.dat.gz']}
def get_legacy_alias():
return setup_helpers.add_legacy_alias(
'vo', 'astropy.io.vo', '0.8')
| from distutils.core import Extension
from os.path import join
from astropy import setup_helpers
def get_extensions(build_type='release'):
VO_DIR = 'astropy/io/vo/src'
return [Extension(
"astropy.io.vo.tablewriter",
[join(VO_DIR, "tablewriter.c")],
include_dirs=[VO_DIR])]
def get_package_data():
return {
'astropy.io.vo': [
'data/ucd1p-words.txt', 'data/*.xsd', 'data/*.dtd'],
'astropy.io.vo.tests': [
'data/*.xml', 'data/*.gz', 'data/*.json', 'data/*.fits',
'data/*.txt'],
'astropy.io.vo.validator': [
'urls/*.dat.gz']}
def get_legacy_alias():
return setup_helpers.add_legacy_alias(
'vo', 'astropy.io.vo', '0.7.2')
| bsd-3-clause | Python |
dc7ac28109609e2a90856dbaf01ae8bbb2fd6985 | Repair the test (adding a docstring to the module type changed the docstring for an uninitialized module object). | sk-/python2.7-type-annotator,sk-/python2.7-type-annotator,sk-/python2.7-type-annotator | Lib/test/test_module.py | Lib/test/test_module.py | # Test the module type
from test_support import verify, vereq, verbose, TestFailed
import sys
module = type(sys)
# An uninitialized module has no __dict__ or __name__, and __doc__ is None
foo = module.__new__(module)
verify(foo.__dict__ is None)
try:
s = foo.__name__
except AttributeError:
pass
else:
raise TestFailed, "__name__ = %s" % repr(s)
vereq(foo.__doc__, module.__doc__)
# Regularly initialized module, no docstring
foo = module("foo")
vereq(foo.__name__, "foo")
vereq(foo.__doc__, None)
vereq(foo.__dict__, {"__name__": "foo", "__doc__": None})
# ASCII docstring
foo = module("foo", "foodoc")
vereq(foo.__name__, "foo")
vereq(foo.__doc__, "foodoc")
vereq(foo.__dict__, {"__name__": "foo", "__doc__": "foodoc"})
# Unicode docstring
foo = module("foo", u"foodoc\u1234")
vereq(foo.__name__, "foo")
vereq(foo.__doc__, u"foodoc\u1234")
vereq(foo.__dict__, {"__name__": "foo", "__doc__": u"foodoc\u1234"})
# Reinitialization should not replace the __dict__
foo.bar = 42
d = foo.__dict__
foo.__init__("foo", "foodoc")
vereq(foo.__name__, "foo")
vereq(foo.__doc__, "foodoc")
vereq(foo.bar, 42)
vereq(foo.__dict__, {"__name__": "foo", "__doc__": "foodoc", "bar": 42})
verify(foo.__dict__ is d)
if verbose:
print "All OK"
| # Test the module type
from test_support import verify, vereq, verbose, TestFailed
import sys
module = type(sys)
# An uninitialized module has no __dict__ or __name__, and __doc__ is None
foo = module.__new__(module)
verify(foo.__dict__ is None)
try:
s = foo.__name__
except AttributeError:
pass
else:
raise TestFailed, "__name__ = %s" % repr(s)
vereq(foo.__doc__, None)
# Regularly initialized module, no docstring
foo = module("foo")
vereq(foo.__name__, "foo")
vereq(foo.__doc__, None)
vereq(foo.__dict__, {"__name__": "foo", "__doc__": None})
# ASCII docstring
foo = module("foo", "foodoc")
vereq(foo.__name__, "foo")
vereq(foo.__doc__, "foodoc")
vereq(foo.__dict__, {"__name__": "foo", "__doc__": "foodoc"})
# Unicode docstring
foo = module("foo", u"foodoc\u1234")
vereq(foo.__name__, "foo")
vereq(foo.__doc__, u"foodoc\u1234")
vereq(foo.__dict__, {"__name__": "foo", "__doc__": u"foodoc\u1234"})
# Reinitialization should not replace the __dict__
foo.bar = 42
d = foo.__dict__
foo.__init__("foo", "foodoc")
vereq(foo.__name__, "foo")
vereq(foo.__doc__, "foodoc")
vereq(foo.bar, 42)
vereq(foo.__dict__, {"__name__": "foo", "__doc__": "foodoc", "bar": 42})
verify(foo.__dict__ is d)
if verbose:
print "All OK"
| mit | Python |
5abac5e7cdc1d67ec6ed0996a5b132fae20af530 | Use the URLs input in the UI boxes | scraperwiki/difference-tool,scraperwiki/difference-tool,scraperwiki/difference-tool,scraperwiki/difference-tool | compare_text_of_urls.py | compare_text_of_urls.py | #!/usr/bin/env python
from __future__ import print_function
import json
import os
from os.path import join, dirname, abspath
import subprocess
import sys
from get_text_from_url import process_page
def main(argv=None):
if argv is None:
argv = sys.argv
arg = argv[1:]
# Enter two URLs with a space between them
if len(arg) > 0:
# Developers can supply URL as an argument...
urls = arg[0]
else:
# ... but normally the URL comes from the allSettings.json file
with open(os.path.expanduser("~/allSettings.json")) as settings_json:
settings = json.load(settings_json)
url1 = settings['source-url']
url2 = settings['source-url2']
assert url1 and url2, 'Two URLs not entered.'
diff_urls(url1, url2)
def diff_urls(url1, url2):
text1 = process_page('text_from_url1', url1)
text2 = process_page('text_from_url2', url2)
subprocess.check_output("./diff_text.sh", cwd=dirname(abspath(__file__)))
if __name__ == '__main__':
main()
| #!/usr/bin/env python
from __future__ import print_function
import json
import os
from os.path import join, dirname, abspath
import subprocess
import sys
from get_text_from_url import process_page
def main(argv=None):
if argv is None:
argv = sys.argv
arg = argv[1:]
# Enter two URLs with a space between them
if len(arg) > 0:
# Developers can supply URL as an argument...
urls = arg[0]
else:
# ... but normally the URL comes from the allSettings.json file
with open(os.path.expanduser("~/allSettings.json")) as settings:
urls = json.load(settings)['source-url']
parsed_urls = urls.strip().split(' ')
assert len(parsed_urls) == 2, 'Two URLs not entered.'
diff_urls(parsed_urls[0], parsed_urls[1])
def diff_urls(url1, url2):
text1 = process_page('text_from_url1', url1)
text2 = process_page('text_from_url2', url2)
subprocess.check_output("./diff_text.sh", cwd=dirname(abspath(__file__)))
if __name__ == '__main__':
main()
| agpl-3.0 | Python |
f81c36d4fe31815ed6692b573ad660067151d215 | Drop use of 'oslo' namespace package | openstack/python-zaqarclient | zaqarclient/_i18n.py | zaqarclient/_i18n.py | # Copyright 2014 Red Hat, Inc
# All Rights .Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_i18n import * # noqa
_translators = TranslatorFactory(domain='zaqarclient')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
| # Copyright 2014 Red Hat, Inc
# All Rights .Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.i18n import * # noqa
_translators = TranslatorFactory(domain='zaqarclient')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
| apache-2.0 | Python |
962114f65db5de4a0e58ebec93ec8f06147ae790 | add RAMONVolume#data | neurodata/ndio,jhuapl-boss/intern,neurodata/ndio,neurodata/ndio,openconnectome/ndio | ndio/ramon/RAMONVolume.py | ndio/ramon/RAMONVolume.py | from __future__ import absolute_import
from .enums import *
from .errors import *
import numpy
from .RAMONBase import RAMONBase
class RAMONVolume(RAMONBase):
"""
RAMONVolume Object for storing neuroscience data with a voxel volume
"""
def __init__(self,
xyz_offset=(0, 0, 0),
resolution=0,
cutout=None,
voxels=None,
id=DEFAULT_ID,
confidence=DEFAULT_CONFIDENCE,
dynamic_metadata=DEFAULT_DYNAMIC_METADATA,
status=DEFAULT_STATUS,
author=DEFAULT_AUTHOR):
"""
Initialize a new RAMONVolume object. Inherits attributes from RAMONBase
as well as:
Arguments:
xyz_offset (int[3] : (0, 0, 0)): x,y,z coordinates of the minimum
corner of the cube (if data is a cutout), otherwise empty
resolution (int : 0): level in the database resolution hierarchy
cutout (numpy.ndarray): dense matrix of data
voxels: Unused for now
"""
self.xyz_offset = xyz_offset
self.resolution = resolution
self.cutout = cutout
self.voxels = voxels
RAMONBase.__init__(self, id=id, confidence=confidence,
dynamic_metadata=dynamic_metadata,
status=status, author=author)
def data(self):
"""
Gets the data from the volume and pumps it into a numpy.ndarray format,
regardless of whether it's stored in `cutout` or `voxels`. Returns it
as though it were stored in `cutout`.
This is useful for cases where you need to operate on a 3D matrix.
Arguments:
None
Returns:
numpy.ndarray
"""
if self.cutout:
return self.cutout
else:
raise NotImplementedError("Cannot convert from voxel list yet.")
| from __future__ import absolute_import
from .enums import *
from .errors import *
import numpy
from .RAMONBase import RAMONBase
class RAMONVolume(RAMONBase):
"""
RAMONVolume Object for storing neuroscience data with a voxel volume
"""
def __init__(self,
xyz_offset=(0, 0, 0),
resolution=0,
cutout=None,
voxels=None,
id=DEFAULT_ID,
confidence=DEFAULT_CONFIDENCE,
dynamic_metadata=DEFAULT_DYNAMIC_METADATA,
status=DEFAULT_STATUS,
author=DEFAULT_AUTHOR):
"""
Initialize a new RAMONVolume object. Inherits attributes from RAMONBase
as well as:
Arguments:
xyz_offset (int[3] : (0, 0, 0)): x,y,z coordinates of the minimum
corner of the cube (if data is a cutout), otherwise empty
resolution (int : 0): level in the database resolution hierarchy
cutout (numpy.ndarray): dense matrix of data
voxels: Unused for now
"""
self.xyz_offset = xyz_offset
self.resolution = resolution
self.cutout = cutout
self.voxels = voxels
RAMONBase.__init__(self, id=id, confidence=confidence,
dynamic_metadata=dynamic_metadata,
status=status, author=author)
| apache-2.0 | Python |
1cba70e91b6592253a74d2c030e9c57faf0a1485 | add header to backend.py | Mustard-Systems-Ltd/pyzmq,yyt030/pyzmq,Mustard-Systems-Ltd/pyzmq,swn1/pyzmq,caidongyun/pyzmq,Mustard-Systems-Ltd/pyzmq,dash-dash/pyzmq,swn1/pyzmq,caidongyun/pyzmq,dash-dash/pyzmq,ArvinPan/pyzmq,ArvinPan/pyzmq,ArvinPan/pyzmq,dash-dash/pyzmq,caidongyun/pyzmq,yyt030/pyzmq,yyt030/pyzmq,swn1/pyzmq | zmq/sugar/backend.py | zmq/sugar/backend.py | """Import basic exposure of libzmq C API as a backend"""
#-----------------------------------------------------------------------------
# Copyright (C) 2013 Brian Granger, Min Ragan-Kelley
#
# This file is part of pyzmq
#
# Distributed under the terms of the New BSD License. The full license is in
# the file COPYING.BSD, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
# this will be try/except when other
try:
from zmq.core import (
Context,
Socket, IPC_PATH_MAX_LEN,
Frame, Message,
Stopwatch,
device, proxy,
strerror, zmq_errno,
zmq_poll,
zmq_version_info,
constants,
)
except ImportError:
# here will be the cffi backend import, when it exists
raise
__all__ = [
'Context',
'Socket',
'Frame',
'Message',
'Stopwatch',
'device',
'proxy',
'zmq_poll',
'strerror',
'zmq_errno',
'constants',
'zmq_version_info',
'IPC_PATH_MAX_LEN',
]
| # this will be try/except when other
try:
from zmq.core import (
Context,
Socket, IPC_PATH_MAX_LEN,
Frame, Message,
Stopwatch,
device, proxy,
strerror, zmq_errno,
zmq_poll,
zmq_version_info,
constants,
)
except ImportError:
# here will be the cffi backend import, when it exists
raise
__all__ = [
'Context',
'Socket',
'Frame',
'Message',
'Stopwatch',
'device',
'proxy',
'zmq_poll',
'strerror',
'zmq_errno',
'constants',
'zmq_version_info',
'IPC_PATH_MAX_LEN',
]
| bsd-3-clause | Python |
9d3d06e760cb4210405a3b720eb67c5da0478f72 | remove succes_message variable | adnedelcu/SyncSettings,mfuentesg/SyncSettings | sync_settings/thread_progress.py | sync_settings/thread_progress.py | # -*- coding: utf-8 -*-
#Credits to @wbond package_control
import sublime, threading
class ThreadProgress():
"""
Animates an indicator, [= ], in the status area while a thread runs
:param thread:
The thread to track for activity
:param message:
The message to display next to the activity indicator
:param success_message:
The message to display once the thread is complete
"""
def __init__(self, thread_target, message):
self.message = message
self.addend = 1
self.size = 8
self.thread = threading.Thread(target=thread_target)
self.thread.start()
sublime.set_timeout(lambda: self.run(0), 100)
def run(self, i):
if not self.thread.is_alive():
return
before = i % self.size
after =(self.size - 1) - before
sublime.status_message('Sync Settings: %s [%s=%s]' %(self.message, ' ' * before, ' ' * after))
if not after: self.addend = -1
if not before: self.addend = 1
i += self.addend
sublime.set_timeout(lambda: self.run(i), 100)
| # -*- coding: utf-8 -*-
#Credits to @wbond package_control
import sublime, threading
class ThreadProgress():
"""
Animates an indicator, [= ], in the status area while a thread runs
:param thread:
The thread to track for activity
:param message:
The message to display next to the activity indicator
:param success_message:
The message to display once the thread is complete
"""
def __init__(self, thread_target, message, success_message = ''):
self.message = message
self.success_message = success_message
self.addend = 1
self.size = 8
self.thread = threading.Thread(target=thread_target)
self.thread.start()
sublime.set_timeout(lambda: self.run(0), 100)
def run(self, i):
if not self.thread.is_alive():
if self.success_message != "":
self.success_message = 'Sync Settings: %s' %(self.success_message)
sublime.status_message(self.success_message)
return
before = i % self.size
after =(self.size - 1) - before
sublime.status_message('Sync Settings: %s [%s=%s]' %(self.message, ' ' * before, ' ' * after))
if not after: self.addend = -1
if not before: self.addend = 1
i += self.addend
sublime.set_timeout(lambda: self.run(i), 100)
| mit | Python |
c691c256682bec5f9a242ab71ab42d296bbf88a9 | Add `Post`, `Tag` models to Admin | avinassh/nightreads,avinassh/nightreads | nightreads/posts/admin.py | nightreads/posts/admin.py | from django.contrib import admin
from .models import Post, Tag
admin.site.register(Post)
admin.site.register(Tag)
| from django.contrib import admin
# Register your models here.
| mit | Python |
e77380401d04feb1ff283add4dca9f6bad57f330 | Rewrite order/tests/MemberViewTests. | noracami/haveaniceday,noracami/haveaniceday | haveaniceday/order/tests.py | haveaniceday/order/tests.py | from django.test import TestCase
from .models import Member
from website_component.models import CustomWebPage, CustomComponent
# Create your tests here.
class OrderViewTests(TestCase):
def test_order_view(self):
response = self.client.get('/order/')
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'order/home.html')
class MemberViewTests(TestCase):
def setUp(self):
member = Member(
kmID='AB123456', edocID='edoc', emailID='abc', name='捕夢網',
location='A局-B分局-C所', title='代理執行秘書')
member.save()
another_member = Member(
name='test')
another_member.save()
page = CustomWebPage(name='人員清單')
page.save()
customcomponent = CustomComponent(name='CustomComponent', value='value')
customcomponent.page = page
customcomponent.save()
def tearDown(self):
Member.objects.all().delete()
def test_member_view(self):
r = self.client.get('/order/member/?id=1')
self.assertContains(r, 'AB123456')
def test_member_all(self):
r = self.client.get('/order/member/all/')
self.assertContains(r, 'test')
self.assertContains(r, 'abc')
| from django.test import TestCase
from .models import Member
# Create your tests here.
class OrderViewTests(TestCase):
def test_order_view(self):
response = self.client.get('/order/')
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'order/home.html')
class MemberViewTests(TestCase):
def setUp(self):
member = Member(
kmID='AB123456', edocID='edoc', emailID='abc', name='捕夢網',
location='A局-B分局-C所', title='代理執行秘書')
member.save()
another_member = Member(
name='test')
another_member.save()
def tearDown(self):
Member.objects.all().delete()
def test_member_view(self):
r = self.client.get('/order/member/?id=1')
self.assertContains(r, 'AB123456')
def test_member_all(self):
r = self.client.get('/order/member/all/')
self.assertContains(r, 'test')
self.assertContains(r, 'abc')
| mit | Python |
4f2b4b07131c462873b87b869e8df1de41af5848 | Add some test code | morrislab/rnascan,morrislab/rnascan,morrislab/rnascan,morrislab/rnascan | RNACompete/SeqStruct.py | RNACompete/SeqStruct.py | # Copyright 2000-2002 Brad Chapman.
# Copyright 2004-2005 by M de Hoon.
# Copyright 2007-2015 by Peter Cock.
# All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
# Modified Copyright 2016 by Kevin Ha
"""This class inherits Bio.Seq that adds functionality for handling
RNAContextualSequenceSecondaryStructure alphabets.
Specifically, will take a RNA sequence and contextual secondary structure
sequence and convert it to a unified RNAContextualSequenceSecondaryStructure
alphabet.
"""
from secondarystructure import RNAContextualSequenceSecondaryStructure as RNASS
from Bio.Seq import Seq
class SeqStruct(Seq):
"""A read-only Sequence object that extends Bio.Seq
Adds extra function for converting RNA sequence and contextual secondary
structure sequence into a RNAContextualSequenceSecondaryStructure sequence
"""
def __init__(self, seq, struct):
# Convert sequence and struct sequences
newseq = SeqStruct.convert(seq, struct)
super(SeqStruct, self).__init__(newseq, RNASS)
@staticmethod
def convert(seq, struct):
"""Convert a seq and struct SeqRecord to a new SeqRecord with
alphabet RNAContextualSequenceSecondaryStructure
"""
if len(seq) != len(struct):
raise ValueError(('Sequence and structure records have'
' different lengths'))
seqstruct_sequence = ''
for i,j in zip(seq, struct):
seqstruct_sequence += RNASS.convert(i, j)
return seqstruct_sequence
if __name__ == "__main__":
s = SeqStruct('AGC', 'BBB')
print s
| # Copyright 2000-2002 Brad Chapman.
# Copyright 2004-2005 by M de Hoon.
# Copyright 2007-2015 by Peter Cock.
# All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
# Modified Copyright 2016 by Kevin Ha
"""This class inherits Bio.Seq that adds functionality for handling
RNAContextualSequenceSecondaryStructure alphabets.
Specifically, will take a RNA sequence and contextual secondary structure
sequence and convert it to a unified RNAContextualSequenceSecondaryStructure
alphabet.
"""
from secondarystructure import RNAContextualSequenceSecondaryStructure as RNASS
from Bio.Seq import Seq
class SeqStruct(Seq):
"""A read-only Sequence object that extends Bio.Seq
Adds extra function for converting RNA sequence and contextual secondary
structure sequence into a RNAContextualSequenceSecondaryStructure sequence
"""
def __init__(self, seq, struct):
# Convert sequence and struct sequences
newseq = SeqStruct.convert(seq, struct)
super(SeqStruct, self).__init__(newseq, RNASS)
@staticmethod
def convert(seq, struct):
"""Convert a seq and struct SeqRecord to a new SeqRecord with
alphabet RNAContextualSequenceSecondaryStructure
"""
if len(seq) != len(struct):
raise ValueError(('Sequence and structure records have'
' different lengths'))
seqstruct_sequence = ''
for i,j in zip(seq, struct):
seqstruct_sequence += RNASS.convert(i, j)
return seqstruct_sequence
| agpl-3.0 | Python |
951c0dbcfeb016dbde6e1a7a3f0eacc506c9211e | Rename sockjs router prefix to /ws/api/ | jessamynsmith/boards-backend,jessamynsmith/boards-backend,GetBlimp/boards-backend | ws.py | ws.py | import json
from tornado import web, ioloop
from sockjs.tornado import SockJSRouter, SockJSConnection
from blimp.utils.websockets import WebSocketsRequest
class RESTAPIConnection(SockJSConnection):
def on_open(self, info):
self.send_json({'connected': True})
def on_message(self, data):
response = WebSocketsRequest(data).get_response()
self.send_json(response)
def send_json(self, obj):
self.send(json.dumps(obj))
if __name__ == '__main__':
import logging
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'--port',
help='Optional port number. Defaults to 8080',
default=8080,
)
parser.add_argument(
'--debug',
help='Verbosity level set to DEBUG. Defaults to WARNING.',
action='store_const',
dest='loglevel',
const=logging.DEBUG,
default=logging.WARNING
)
parser.add_argument(
'--verbose',
help='Verbosity level set to INFO.',
action='store_const',
dest='loglevel',
const=logging.INFO
)
args = parser.parse_args()
port = args.port
logging.getLogger().setLevel(args.loglevel)
EchoRouter = SockJSRouter(RESTAPIConnection, '/ws/api/')
app = web.Application(EchoRouter.urls)
app.listen(port)
logging.info(" [*] Listening on 0.0.0.0:{}".format(port))
ioloop.IOLoop.instance().start()
| import json
from tornado import web, ioloop
from sockjs.tornado import SockJSRouter, SockJSConnection
from blimp.utils.websockets import WebSocketsRequest
class EchoConnection(SockJSConnection):
def on_open(self, info):
self.send_json({'connected': True})
def on_message(self, data):
response = WebSocketsRequest(data).get_response()
self.send_json(response)
def send_json(self, obj):
self.send(json.dumps(obj))
if __name__ == '__main__':
import logging
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--port',
help='Optional port number. Defaults to 8080',
default=8080,
)
parser.add_argument('--debug',
help='Verbosity level set to DEBUG. Defaults to WARNING.',
action='store_const',
dest='loglevel',
const=logging.DEBUG,
default=logging.WARNING
)
parser.add_argument('--verbose',
help='Verbosity level set to INFO.',
action='store_const',
dest='loglevel',
const=logging.INFO
)
args = parser.parse_args()
port = args.port
logging.getLogger().setLevel(args.loglevel)
EchoRouter = SockJSRouter(EchoConnection, '/echo')
app = web.Application(EchoRouter.urls)
app.listen(port)
logging.info(" [*] Listening on 0.0.0.0:{}".format(port))
ioloop.IOLoop.instance().start()
| agpl-3.0 | Python |
4fe8a1c1b294f0d75a901d4e8e80f47f5583e44e | Fix for test failure introduced by basic auth changes | edx/edx-e2e-tests,raeeschachar/edx-e2e-mirror,raeeschachar/edx-e2e-mirror,edx/edx-e2e-tests | pages/lms/info.py | pages/lms/info.py | from e2e_framework.page_object import PageObject
from ..lms import BASE_URL
class InfoPage(PageObject):
"""
Info pages for the main site.
These are basically static pages, so we use one page
object to represent them all.
"""
# Dictionary mapping section names to URL paths
SECTION_PATH = {
'about': '/about',
'faq': '/faq',
'press': '/press',
'contact': '/contact',
'terms': '/tos',
'privacy': '/privacy',
'honor': '/honor',
}
# Dictionary mapping URLs to expected css selector
EXPECTED_CSS = {
'/about': 'section.vision',
'/faq': 'section.faq',
'/press': 'section.press',
'/contact': 'section.contact',
'/tos': 'section.tos',
'/privacy': 'section.privacy-policy',
'/honor': 'section.honor-code',
}
@property
def name(self):
return "lms.info"
@property
def requirejs(self):
return []
@property
def js_globals(self):
return []
def url(self, section=None):
return BASE_URL + self.SECTION_PATH[section]
def is_browser_on_page(self):
# Find the appropriate css based on the URL
for url_path, css_sel in self.EXPECTED_CSS.iteritems():
if self.browser.url.endswith(url_path):
return self.is_css_present(css_sel)
# Could not find the CSS based on the URL
return False
@classmethod
def sections(cls):
return cls.SECTION_PATH.keys()
| from e2e_framework.page_object import PageObject
from ..lms import BASE_URL
class InfoPage(PageObject):
"""
Info pages for the main site.
These are basically static pages, so we use one page
object to represent them all.
"""
# Dictionary mapping section names to URL paths
SECTION_PATH = {
'about': '/about',
'faq': '/faq',
'press': '/press',
'contact': '/contact',
'terms': '/tos',
'privacy': '/privacy',
'honor': '/honor',
}
# Dictionary mapping URLs to expected css selector
EXPECTED_CSS = {
'/about': 'section.vision',
'/faq': 'section.faq',
'/press': 'section.press',
'/contact': 'section.contact',
'/tos': 'section.tos',
'/privacy': 'section.privacy-policy',
'/honor': 'section.honor-code',
}
@property
def name(self):
return "lms.info"
@property
def requirejs(self):
return []
@property
def js_globals(self):
return []
def url(self, section=None):
return BASE_URL + self.SECTION_PATH[section]
def is_browser_on_page(self):
stripped_url = self.browser.url.replace(BASE_URL, "")
css_sel = self.EXPECTED_CSS[stripped_url]
return self.is_css_present(css_sel)
@classmethod
def sections(cls):
return cls.SECTION_PATH.keys()
| agpl-3.0 | Python |
4d942291734641bbdd6a71e16167fefca37a68e7 | Fix default config file path on auto creation | eiginn/passpie,marcwebbie/passpie,scorphus/passpie,scorphus/passpie,marcwebbie/passpie,eiginn/passpie | passpie/config.py | passpie/config.py | import copy
import logging
import os
import yaml
DEFAULT_CONFIG_PATH = os.path.join(os.path.expanduser('~'), '.passpierc')
DB_DEFAULT_PATH = os.path.join(os.path.expanduser('~'), '.passpie')
DEFAULT_CONFIG = {
'path': DB_DEFAULT_PATH,
'short_commands': False,
'key_length': 4096,
'genpass_length': 32,
'genpass_symbols': "_-#|+=",
'table_format': 'fancy_grid',
'headers': ['name', 'login', 'password', 'comment'],
'colors': {'name': 'yellow', 'login': 'green'},
'repo': True,
'status_repeated_passwords_limit': 5,
'copy_timeout': 0,
'extension': '.pass',
'recipient': None
}
def read_config(path):
try:
with open(path) as config_file:
content = config_file.read()
config = yaml.load(content)
except IOError:
logging.debug('config file "%s" not found' % path)
return {}
except yaml.scanner.ScannerError as e:
logging.error('Malformed user configuration file {}'.format(e))
return {}
return config
def create(path, default=True, **kwargs):
config_path = os.path.join(os.path.expanduser(path), '.passpierc')
with open(config_path, 'w') as config_file:
if default:
config_file.write(yaml.dump(DEFAULT_CONFIG, default_flow_style=False))
else:
config_file.write(yaml.dump(kwargs, default_flow_style=False))
def load():
if not os.path.isfile(DEFAULT_CONFIG_PATH):
create(DEFAULT_CONFIG_PATH, default=True)
global_config = read_config(DEFAULT_CONFIG_PATH)
config = copy.deepcopy(DEFAULT_CONFIG)
config.update(global_config)
local_config = read_config(os.path.join(config['path'], '.passpierc'))
config.update(local_config)
return config
| import copy
import logging
import os
import yaml
DEFAULT_CONFIG_PATH = os.path.join(os.path.expanduser('~'), '.passpierc')
DB_DEFAULT_PATH = os.path.join(os.path.expanduser('~'), '.passpie')
DEFAULT_CONFIG = {
'path': DB_DEFAULT_PATH,
'short_commands': False,
'key_length': 4096,
'genpass_length': 32,
'genpass_symbols': "_-#|+=",
'table_format': 'fancy_grid',
'headers': ['name', 'login', 'password', 'comment'],
'colors': {'name': 'yellow', 'login': 'green'},
'repo': True,
'status_repeated_passwords_limit': 5,
'copy_timeout': 0,
'extension': '.pass',
'recipient': None
}
def read_config(path):
try:
with open(path) as config_file:
content = config_file.read()
config = yaml.load(content)
except IOError:
logging.debug('config file "%s" not found' % path)
return {}
except yaml.scanner.ScannerError as e:
logging.error('Malformed user configuration file {}'.format(e))
return {}
return config
def create(path, default=True, **kwargs):
config_path = os.path.join(os.path.expanduser(path), '.passpierc')
with open(config_path, 'w') as config_file:
if default:
config_file.write(yaml.dump(DEFAULT_CONFIG, default_flow_style=False))
else:
config_file.write(yaml.dump(kwargs, default_flow_style=False))
def load():
if not os.path.isfile(DEFAULT_CONFIG_PATH):
create(DEFAULT_CONFIG['path'], default=True)
global_config = read_config(DEFAULT_CONFIG_PATH)
config = copy.deepcopy(DEFAULT_CONFIG)
config.update(global_config)
local_config = read_config(os.path.join(config['path'], '.passpierc'))
config.update(local_config)
return config
| mit | Python |
2559fa50a80ac90f36c3aed251bf397f1af83dd2 | bump version to 0.1b2 | fkmclane/paste,fkmclane/paste | paste/__init__.py | paste/__init__.py | name = 'paste'
version = '0.1b2'
| name = 'paste'
version = '0.1b1'
| mit | Python |
a9808c822e598fd17148b8fc4063ea11f0a270e9 | Add bawler specific exception | beezz/pg_bawler,beezz/pg_bawler | pg_bawler/core.py | pg_bawler/core.py | '''
==============
pg_bawler.core
==============
Base classes for LISTEN / NOTIFY.
Postgresql documentation for
`LISTEN <https://www.postgresql.org/docs/current/static/sql-listen.html>`_ /
`NOTIFY <https://www.postgresql.org/docs/current/static/sql-notify.html>`_.
'''
import asyncio
import logging
import aiopg
LOGGER = logging.getLogger(name='pg_bawler.core')
class PgBawlerException(Exception):
'''
Base class for all ``pg_bawler`` related failures
'''
def cache_async_def(func):
cache_attr_name = '_cache_async_def_{func.__name__}'.format(func=func)
async def _cache_method(self, *args, **kwargs):
if not hasattr(self, cache_attr_name):
setattr(self, cache_attr_name, await func(self, *args, **kwargs))
return getattr(self, cache_attr_name)
# simulate functools.update_wrapper
_cache_method.__name__ = func.__name__
_cache_method.__doc__ = func.__doc__
_cache_method.__module__ = func.__module__
# save cache_attr_name on function
# so delattr(self, func.cache_attr_name) will clear the cache
_cache_method.cache_attr_name = cache_attr_name
return _cache_method
class BawlerBase:
'''
Base ``pg_bawler`` class with convenience methods around ``aiopg``.
'''
def __init__(self, connection_params, *, loop=None):
self.connection_params = connection_params
self._connection = None
self.loop = asyncio.get_event_loop() if loop is None else loop
@cache_async_def
async def pg_pool(self):
return await aiopg.create_pool(
loop=self.loop, **self.connection_params)
@cache_async_def
async def pg_connection(self):
return await (await self.pg_pool()).acquire()
async def drop_connection(self):
'''
Drops current connection
Next call to the ``self.pg_connection`` will acquire new connection
from pool. Use this method to drop dead connections on server restart.
'''
if hasattr(self, self.pg_connection.cache_attr_name):
pg_conn = (await self.pg_connection())
pg_conn.close()
await (await self.pg_pool()).release(pg_conn)
# clear cached connection property (cache_async_def)
delattr(self, self.pg_connection.cache_attr_name)
async def __aenter__(self):
return self
async def __aexit__(self, exc_type, exc, tb):
await self.drop_connection()
| '''
==============
pg_bawler.core
==============
Base classes for LISTEN / NOTIFY.
Postgresql documentation for
`LISTEN <https://www.postgresql.org/docs/current/static/sql-listen.html>`_ /
`NOTIFY <https://www.postgresql.org/docs/current/static/sql-notify.html>`_.
'''
import asyncio
import logging
import aiopg
LOGGER = logging.getLogger(name='pg_bawler.core')
def cache_async_def(func):
cache_attr_name = '_cache_async_def_{func.__name__}'.format(func=func)
async def _cache_method(self, *args, **kwargs):
if not hasattr(self, cache_attr_name):
setattr(self, cache_attr_name, await func(self, *args, **kwargs))
return getattr(self, cache_attr_name)
# simulate functools.update_wrapper
_cache_method.__name__ = func.__name__
_cache_method.__doc__ = func.__doc__
_cache_method.__module__ = func.__module__
# save cache_attr_name on function
# so delattr(self, func.cache_attr_name) will clear the cache
_cache_method.cache_attr_name = cache_attr_name
return _cache_method
class BawlerBase:
'''
Base ``pg_bawler`` class with convenience methods around ``aiopg``.
'''
def __init__(self, connection_params, *, loop=None):
self.connection_params = connection_params
self._connection = None
self.loop = asyncio.get_event_loop() if loop is None else loop
@cache_async_def
async def pg_pool(self):
return await aiopg.create_pool(
loop=self.loop, **self.connection_params)
@cache_async_def
async def pg_connection(self):
return await (await self.pg_pool()).acquire()
async def drop_connection(self):
'''
Drops current connection
Next call to the ``self.pg_connection`` will acquire new connection
from pool. Use this method to drop dead connections on server restart.
'''
if hasattr(self, self.pg_connection.cache_attr_name):
pg_conn = (await self.pg_connection())
pg_conn.close()
await (await self.pg_pool()).release(pg_conn)
# clear cached connection property (cache_async_def)
delattr(self, self.pg_connection.cache_attr_name)
async def __aenter__(self):
return self
async def __aexit__(self, exc_type, exc, tb):
await self.drop_connection()
| bsd-3-clause | Python |
d350c180606060e9539c12d7d49eed4d6802ac8b | Bump to 1.1.5 | kezabelle/pilkit,fladi/pilkit | pilkit/pkgmeta.py | pilkit/pkgmeta.py | __title__ = 'pilkit'
__author__ = 'Matthew Tretter'
__version__ = '1.1.5'
__license__ = 'BSD'
__all__ = ['__title__', '__author__', '__version__', '__license__']
| __title__ = 'pilkit'
__author__ = 'Matthew Tretter'
__version__ = '1.1.4'
__license__ = 'BSD'
__all__ = ['__title__', '__author__', '__version__', '__license__']
| bsd-3-clause | Python |
3ce78ad88d8c963dfb819b323b40b2415d8624b2 | Split create user feature into two functions | brianquach/udacity-nano-fullstack-game | api.py | api.py | #!/usr/bin/env python
"""
Copyright 2016 Brian Quach
Licensed under MIT (https://github.com/brianquach/udacity-nano-fullstack-conference/blob/master/LICENSE) # noqa
"""
import endpoints
from protorpc import remote
from resource import StringMessage
from resource import USER_REQUEST
@endpoints.api(name='poker', version='v1')
class FiveCardPokerAPI(remote.Service):
"""An API for a two-player five card poker game."""
@endpoints.method(
request_message=USER_REQUEST,
response_message=StringMessage,
path='user/create',
name='createUser',
http_method='POST'
)
def create_user(self, request):
"""Create a player."""
return self._create_user(request)
def _create_user(request):
"""Create a player.
Username must be unique.
Code Citation:
https://github.com/udacity/FSND-P4-Design-A-Game/blob/master/Skeleton%20Project%20Guess-a-Number/api.py # noqa
"""
if User.query(User.name == request.user_name).get():
raise endpoints.ConflictException(
'A User with that name already exists!'
)
user = User(name=request.user_name, email=request.email)
user.put()
return StringMessage(message='User {} created!'.format(
request.user_name))
api = endpoints.api_server([FiveCardPokerAPI])
| #!/usr/bin/env python
"""
Copyright 2016 Brian Quach
Licensed under MIT (https://github.com/brianquach/udacity-nano-fullstack-conference/blob/master/LICENSE) # noqa
"""
import endpoints
from protorpc import remote
from resource import StringMessage
from resource import USER_REQUEST
@endpoints.api(name='poker', version='v1')
class FiveCardPokerAPI(remote.Service):
"""An API for a two-player five card poker game."""
# Players are delt a five card hand and each player has one opportunity,
# starting with player one, to replace up to 5 cards in their hand with new
# cards from the top of the deck.
# Once each player has finished replacing their cards, each hand is then
# revealed. The player with the highest poker hand wins.
# Username must be unique.
# Code Citation:
# https://github.com/udacity/FSND-P4-Design-A-Game/blob/master/Skeleton%20Project%20Guess-a-Number/api.py # noqa
@endpoints.method(
request_message=USER_REQUEST,
response_message=StringMessage,
path='user/create',
name='createUser',
http_method='POST'
)
def create_user(self, request):
"""Create a User."""
if User.query(User.name == request.user_name).get():
raise endpoints.ConflictException(
'A User with that name already exists!'
)
user = User(name=request.user_name, email=request.email)
user.put()
return StringMessage(message='User {} created!'.format(
request.user_name))
api = endpoints.api_server([FiveCardPokerAPI])
| mit | Python |
ce8ba26877505481795edd024c3859b14c548ffd | Refactor comics.py | dhinakg/BitSTAR,StarbotDiscord/Starbot,dhinakg/BitSTAR,StarbotDiscord/Starbot | plugins/comics.py | plugins/comics.py | # Copyright 2017 Starbot Discord Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
'''Get comics from xkcd.'''
import json
from api import command, caching, message, plugin
def onInit(plugin_in):
'''List commands for plugin.'''
xkcd_command = command.command(plugin_in, 'xkcd', shortdesc='Posts the latest XKCD, or by specific ID')
return plugin.plugin(plugin_in, 'comics', [xkcd_command])
async def onCommand(message_in):
'''Run plugin commands.'''
if message_in.command == 'xkcd':
if message_in.body:
try:
if int(message_in.body) < 0:
return message.message(body="ID `{}` is not a valid ID".format(message_in.body))
except ValueError:
return message.message(body='Input of `{}` is not a valid number'.format(message_in.body))
data = json.loads(caching.getJson("https://xkcd.com/{}/info.0.json".format(message_in.body.strip()),
caller='xkcd',
customName='{}.json'.format(message_in.body.strip())))
else:
data = json.loads(caching.getJson("https://xkcd.com/info.0.json", caller='xkcd', save=False))
caching.downloadToCache(data['img'], '{}.png'.format(data['num']), caller='xkcd')
return message.message(body='**{}/{}/{} - {}**\n_{}_'.format(data['month'], data['day'], data['year'],
data['safe_title'], data['alt']),
file='cache/xkcd_{}.png'.format(data['num']))
| # Copyright 2017 Starbot Discord Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from api import command, caching, message, plugin
def onInit(plugin_in):
xkcd_command = command.command(plugin_in, 'xkcd', shortdesc='Posts the latest XKCD, or by specific ID')
return plugin.plugin(plugin_in, 'comics', [xkcd_command])
async def onCommand(message_in):
if message_in.command == 'xkcd':
if message_in.body != '':
try:
if int(message_in.body) < 0:
return message.message(body="ID `{}` is not a valid ID".format(message_in.body))
except:
return message.message(body='Input of `{}` is not a valid number'.format(message_in.body))
data = json.loads(caching.getJson("https://xkcd.com/{}/info.0.json".format(message_in.body.strip()),
caller='xkcd',
customName='{}.json'.format(message_in.body.strip())))
else:
data = json.loads(caching.getJson("https://xkcd.com/info.0.json", caller='xkcd', save=False))
caching.downloadToCache(data['img'], '{}.png'.format(data['num']), caller='xkcd')
return message.message(body='**{}/{}/{} - {}**\n_{}_'.format(data['month'], data['day'], data['year'], data['safe_title'], data['alt']),
file='cache/xkcd_{}.png'.format(data['num'])) | apache-2.0 | Python |
318e6b5fd2382766c065574f6b202fd09e68cf6e | increment version # | lfairchild/PmagPy,lfairchild/PmagPy,lfairchild/PmagPy | pmagpy/version.py | pmagpy/version.py | """
Module contains current pmagpy version number.
Version number is displayed by GUIs
and used by setuptools to assign number to pmagpy/pmagpy-cli.
"""
"pmagpy-3.11.1"
version = 'pmagpy-3.11.1'
| """
Module contains current pmagpy version number.
Version number is displayed by GUIs
and used by setuptools to assign number to pmagpy/pmagpy-cli.
"""
"pmagpy-3.11.0"
version = 'pmagpy-3.11.0'
| bsd-3-clause | Python |
7150413cccbf8f812b3fd4a1fc2b82a4020aed9f | fix heroku postgresql path to allow sqlalchemy upgrade | Impactstory/paperbuzz-api,Impactstory/paperbuzz-api | app.py | app.py | from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_compress import Compress
from flask_debugtoolbar import DebugToolbarExtension
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
from sqlalchemy.pool import NullPool
import logging
import sys
import os
import requests
HEROKU_APP_NAME = "paperbuzz-api"
# set up logging
# see http://wiki.pylonshq.com/display/pylonscookbook/Alternative+logging+configuration
logging.basicConfig(
stream=sys.stdout, level=logging.DEBUG, format="%(name)s - %(message)s"
)
logger = logging.getLogger("paperbuzz")
libraries_to_mum = [
"requests.packages.urllib3",
"requests_oauthlib",
"stripe",
"oauthlib",
"boto",
"newrelic",
"RateLimiter",
]
for a_library in libraries_to_mum:
the_logger = logging.getLogger(a_library)
the_logger.setLevel(logging.WARNING)
the_logger.propagate = True
requests.packages.urllib3.disable_warnings()
# error reporting with sentry
sentry_sdk.init(
dsn=os.environ.get('SENTRY_DSN'),
integrations=[FlaskIntegration()]
)
app = Flask(__name__)
# database stuff
app.config[
"SQLALCHEMY_TRACK_MODIFICATIONS"
] = True # as instructed, to suppress warning
db_uri = os.getenv("DATABASE_URL")
if db_uri.startswith("postgres://"):
db_uri = db_uri.replace("postgres://", "postgresql://", 1) # temp heroku sqlalchemy fix
app.config["SQLALCHEMY_DATABASE_URI"] = db_uri
app.config["SQLALCHEMY_ECHO"] = os.getenv("SQLALCHEMY_ECHO", False) == "True"
# from http://stackoverflow.com/a/12417346/596939
class NullPoolSQLAlchemy(SQLAlchemy):
def apply_driver_hacks(self, app, info, options):
options["poolclass"] = NullPool
return super(NullPoolSQLAlchemy, self).apply_driver_hacks(app, info, options)
db = NullPoolSQLAlchemy(app)
# do compression. has to be above flask debug toolbar so it can override this.
compress_json = os.getenv("COMPRESS_DEBUG", "False") == "True"
# set up Flask-DebugToolbar
if os.getenv("FLASK_DEBUG", False) == "True":
logger.info("Setting app.debug=True; Flask-DebugToolbar will display")
compress_json = False
app.debug = True
app.config["DEBUG"] = True
app.config["DEBUG_TB_INTERCEPT_REDIRECTS"] = False
app.config["SQLALCHEMY_RECORD_QUERIES"] = True
app.config["SECRET_KEY"] = os.getenv("SECRET_KEY")
toolbar = DebugToolbarExtension(app)
# gzip responses
Compress(app)
app.config["COMPRESS_DEBUG"] = compress_json
| from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_compress import Compress
from flask_debugtoolbar import DebugToolbarExtension
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
from sqlalchemy.pool import NullPool
import logging
import sys
import os
import requests
HEROKU_APP_NAME = "paperbuzz-api"
# set up logging
# see http://wiki.pylonshq.com/display/pylonscookbook/Alternative+logging+configuration
logging.basicConfig(
stream=sys.stdout, level=logging.DEBUG, format="%(name)s - %(message)s"
)
logger = logging.getLogger("paperbuzz")
libraries_to_mum = [
"requests.packages.urllib3",
"requests_oauthlib",
"stripe",
"oauthlib",
"boto",
"newrelic",
"RateLimiter",
]
for a_library in libraries_to_mum:
the_logger = logging.getLogger(a_library)
the_logger.setLevel(logging.WARNING)
the_logger.propagate = True
requests.packages.urllib3.disable_warnings()
# error reporting with sentry
sentry_sdk.init(
dsn=os.environ.get('SENTRY_DSN'),
integrations=[FlaskIntegration()]
)
app = Flask(__name__)
# database stuff
app.config[
"SQLALCHEMY_TRACK_MODIFICATIONS"
] = True # as instructed, to suppress warning
app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("DATABASE_URL")
app.config["SQLALCHEMY_ECHO"] = os.getenv("SQLALCHEMY_ECHO", False) == "True"
# from http://stackoverflow.com/a/12417346/596939
class NullPoolSQLAlchemy(SQLAlchemy):
def apply_driver_hacks(self, app, info, options):
options["poolclass"] = NullPool
return super(NullPoolSQLAlchemy, self).apply_driver_hacks(app, info, options)
db = NullPoolSQLAlchemy(app)
# do compression. has to be above flask debug toolbar so it can override this.
compress_json = os.getenv("COMPRESS_DEBUG", "False") == "True"
# set up Flask-DebugToolbar
if os.getenv("FLASK_DEBUG", False) == "True":
logger.info("Setting app.debug=True; Flask-DebugToolbar will display")
compress_json = False
app.debug = True
app.config["DEBUG"] = True
app.config["DEBUG_TB_INTERCEPT_REDIRECTS"] = False
app.config["SQLALCHEMY_RECORD_QUERIES"] = True
app.config["SECRET_KEY"] = os.getenv("SECRET_KEY")
toolbar = DebugToolbarExtension(app)
# gzip responses
Compress(app)
app.config["COMPRESS_DEBUG"] = compress_json
| mit | Python |
b8bf769d55a61f9d29b15c4b657d9df293045304 | convert to int | cbott/RobotServer,cbott/RobotServer,cbott/RobotServer | app.py | app.py | #!/usr/bin/env python
from flask import Flask, render_template, Response, request
from i2c import I2C
from camera_pi import Camera
RobotArduino = I2C(); #The robot's arduino controller
app = Flask(__name__, template_folder='site')
@app.route('/')
def index():
"""Main page: controller + video stream"""
return render_template('index.html')
@app.route('/action', methods=['POST'])
def action():
"""Handle button presses - Send commands to the robot"""
val = request.form.get('command')
print("Sending ["+str(val)+"] To Arduino")
RobotArduino.writeNumber(int(val))
return ('',204) #no response
def gen(camera):
"""Video streaming generator function."""
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@app.route('/video_feed')
def video_feed():
"""Video streaming route. Put this in the src attribute of an img tag."""
return Response(gen(Camera()), mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True, threaded=True, port=8000)
| #!/usr/bin/env python
from flask import Flask, render_template, Response, request
from i2c import I2C
from camera_pi import Camera
RobotArduino = I2C(); #The robot's arduino controller
app = Flask(__name__, template_folder='site')
@app.route('/')
def index():
"""Main page: controller + video stream"""
return render_template('index.html')
@app.route('/action', methods=['POST'])
def action():
"""Handle button presses - Send commands to the robot"""
val = request.form.get('command')
print("Sending ["+str(val)+"] To Arduino")
RobotArduino.writeNumber(val)
return ('',204) #no response
def gen(camera):
"""Video streaming generator function."""
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@app.route('/video_feed')
def video_feed():
"""Video streaming route. Put this in the src attribute of an img tag."""
return Response(gen(Camera()), mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True, threaded=True, port=8000)
| mit | Python |
f67807b0f2064e1c6374fe4c10ed87c7a9222426 | mark all events after processing it | Zauberstuhl/foaasBot | bot.py | bot.py | #! /usr/bin/env python
from time import gmtime, strftime
from foaas import foaas
from diaspy_client import Client
import re
import urllib2
def log_write(text):
f = open('bot.log', 'a')
f.write(strftime("%a, %d %b %Y %H:%M:%S ", gmtime()))
f.write(text)
f.write('\n')
f.close()
client=Client()
notify = client.notifications()
for n in notify:
if not n.unread: continue
m = re.search('\shas\smentioned.+post\s([^\/]+)\s(.+)\.+$', str(n))
try:
if hasattr(m, 'group'):
command = m.group(2).replace(' ', '__')
client.post(foaas(command))
except urllib2.URLError:
log_write("ERROR: "+str(n))
# finally mark as read
n.mark()
| #! /usr/bin/env python
from time import gmtime, strftime
from foaas import foaas
from diaspy_client import Client
import re
import urllib2
def log_write(text):
f = open('bot.log', 'a')
f.write(strftime("%a, %d %b %Y %H:%M:%S ", gmtime()))
f.write(text)
f.write('\n')
f.close()
client=Client()
notify = client.notifications()
for n in notify:
if not n.unread: continue
m = re.search('\shas\smentioned.+post\s([^\/]+)\s(.+)\.+$', str(n))
try:
if hasattr(m, 'group'):
command = m.group(2).replace(' ', '__')
client.post(foaas(command))
# finally mark as read
n.mark()
except urllib2.URLError:
log_write("ERROR: "+str(n))
| mit | Python |
fae0989a5dc6886b11896f6ba5c6484cd1c1f735 | Fix error on unknown command and blank game name | flukiluke/eris | bot.py | bot.py | import asyncio
import discord
import text_adventure
class Bot(object):
def __init__(self, client, config):
self.client = client
self.config = config
self.game_obj = None
@asyncio.coroutine
def do_command(self, message, command, *args):
try:
yield from getattr(self, command)(message, *args)
except AttributeError:
pass
@asyncio.coroutine
def game(self, message, command, *args):
yield from getattr(self, 'game_' + command)(message, *args)
@asyncio.coroutine
def game_start(self, message, name):
if self.game_obj is not None:
return
self.game_obj = text_adventure.Game(self.config, name)
yield from self.client.change_presence(game = discord.Game(name = name))
yield from self.client.send_message(message.channel, self.game_obj.output())
@asyncio.coroutine
def game_input(self, message, inp):
if self.game_obj is None:
return
self.game_obj.inp(inp)
yield from self.client.send_message(message.channel, self.game_obj.output())
@asyncio.coroutine
def game_end(self, message):
if self.game_obj is None:
return
self.game_obj.stop()
self.game_obj = None
yield from self.client.change_presence(game = None)
@asyncio.coroutine
def parse_chatter(self, message):
if message.content.lower() == 'so' or ':so:' in message.content.lower():
yield from self.client.send_message(message.channel, 'so')
elif message.content.startswith(self.config['game_prefix']) and self.game_obj is not None:
yield from self.game_input(message, message.content[1:])
| import asyncio
import discord
import text_adventure
class Bot(object):
def __init__(self, client, config):
self.client = client
self.config = config
self.game_obj = None
@asyncio.coroutine
def do_command(self, message, command, *args):
yield from getattr(self, command)(message, *args)
@asyncio.coroutine
def game(self, message, command, *args):
yield from getattr(self, 'game_' + command)(message, *args)
@asyncio.coroutine
def game_start(self, message, name):
if self.game_obj is not None:
return
self.game_obj = text_adventure.Game(self.config, name)
yield from self.client.change_presence(game = discord.Game(name = name))
yield from self.client.send_message(message.channel, self.game_obj.output())
@asyncio.coroutine
def game_input(self, message, inp):
if self.game_obj is None:
return
self.game_obj.inp(inp)
yield from self.client.send_message(message.channel, self.game_obj.output())
@asyncio.coroutine
def game_end(self, message):
if self.game_obj is None:
return
self.game_obj.stop()
self.game_obj = None
yield from self.client.change_presence(game = discord.Game(name = ''))
@asyncio.coroutine
def parse_chatter(self, message):
if message.content.lower() == 'so' or ':so:' in message.content.lower():
yield from self.client.send_message(message.channel, 'so')
elif message.content.startswith(self.config['game_prefix']) and self.game_obj is not None:
yield from self.game_input(message, message.content[1:])
| mit | Python |
b8fb30a06ff15000a2d7542e7089b6c8ac1074e5 | Add --allow-drilled flag to cli.py, and increase recursion limit | matthewearl/strippy | cli.py | cli.py | # Copyright (c) 2015 Matthew Earl
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
Command line interface for solving a placement problem.
"""
__all__ = (
'main',
)
import argparse
import sys
import placer
import svg
def main(board, components, nets, args=None):
sys.setrecursionlimit(100000)
parser = argparse.ArgumentParser( description='Find circuit placements.')
parser.add_argument('--first-only', action='store_true',
help="Only output the first solution")
parser.add_argument('--allow-drilled', action='store_true',
help="Allow holes to be drilled out")
parser.add_argument('--svg', nargs='?', const=True,
help="Output SVG for the solutions")
parsed_args = parser.parse_args(args if args is not None else sys.argv[1:])
placement_iter = placer.place(board, components, nets,
allow_drilled=parsed_args.allow_drilled)
if parsed_args.first_only:
placement_iter = [next(placement_iter)]
if not parsed_args.svg:
count = 0
for placement in placement_iter:
placement.print_solution()
print()
count += 1
print("{} solutions".format(count))
else:
if isinstance(parsed_args.svg, str):
with open(parsed_args.svg, "w") as f:
svg.print_svg(placement_iter, file=f)
else:
svg.print_svg(placement_iter, file=sys.stdout)
| # Copyright (c) 2015 Matthew Earl
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
Command line interface for solving a placement problem.
"""
__all__ = (
'main',
)
import argparse
import sys
import placer
import svg
def main(board, components, nets, args=None):
parser = argparse.ArgumentParser( description='Find circuit placements.')
parser.add_argument('--first-only', action='store_true',
help="Only output the first solution")
parser.add_argument('--svg', nargs='?', const=True,
help="Output SVG for the solutions")
parsed_args = parser.parse_args(args if args is not None else sys.argv[1:])
placement_iter = placer.place(board, components, nets)
if parsed_args.first_only:
placement_iter = [next(placement_iter)]
if not parsed_args.svg:
count = 0
for placement in placement_iter:
placement.print_solution()
print()
count += 1
print("{} solutions".format(count))
else:
if isinstance(parsed_args.svg, str):
with open(parsed_args.svg, "w") as f:
svg.print_svg(placement_iter, file=f)
else:
svg.print_svg(placement_iter, file=sys.stdout)
| mit | Python |
2352ce413cebb9f0fd7b1f26bb33bd0325abedfd | make more pylint friendly | rouault/pycsw,kalxas/pycsw,PublicaMundi/pycsw,geopython/pycsw,mwengren/pycsw,benhowell/pycsw,kevinpdavies/pycsw,ingenieroariel/pycsw,tomkralidis/pycsw,ricardogsilva/pycsw,ckan-fcd/pycsw-fcd,tomkralidis/pycsw,rouault/pycsw,benhowell/pycsw,mwengren/pycsw,kalxas/pycsw,kalxas/pycsw,ricardogsilva/pycsw,ocefpaf/pycsw,bukun/pycsw,ingenieroariel/pycsw,PublicaMundi/pycsw,ckan-fcd/pycsw-fcd,ricardogsilva/pycsw,geopython/pycsw,geopython/pycsw,bukun/pycsw,bukun/pycsw,ocefpaf/pycsw,kevinpdavies/pycsw,tomkralidis/pycsw | csw.py | csw.py | #!/usr/bin/python -u
# -*- coding: ISO-8859-15 -*-
# =================================================================
#
# $Id$
#
# Authors: Tom Kralidis <tomkralidis@hotmail.com>
#
# Copyright (c) 2010 Tom Kralidis
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================
import os
from server import server
CONFIG = 'default.cfg'
if os.environ['QUERY_STRING'].lower().find('config') != -1:
for kvp in os.environ['QUERY_STRING'].split('&'):
if kvp.lower().find('config') != -1:
CONFIG = kvp.split('=')[1]
# get runtime configuration
CSW = server.Csw(CONFIG)
# go!
CSW.dispatch()
| #!/usr/bin/python -u
# -*- coding: ISO-8859-15 -*-
# =================================================================
#
# $Id$
#
# Authors: Tom Kralidis <tomkralidis@hotmail.com>
#
# Copyright (c) 2010 Tom Kralidis
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================
import os
from server import server
config = 'default.cfg'
if os.environ['QUERY_STRING'].lower().find('config') != -1:
for kvp in os.environ['QUERY_STRING'].split('&'):
if kvp.lower().find('config') != -1:
config = kvp.split('=')[1]
# get runtime configuration
CSW = server.Csw(config)
# go!
CSW.dispatch()
| mit | Python |
22aead72594e5aa7047858c04beb3018e93c59fe | Revert "started 0.2.x" | vsemionov/boomerang,vsemionov/boomerang,vsemionov/boomerang | api/apps.py | api/apps.py | from __future__ import unicode_literals
from django.apps import AppConfig
APP_NAME = 'vsemionov.notes.api'
APP_VERSION = '0.1.0'
class ApiConfig(AppConfig):
name = 'api'
| from __future__ import unicode_literals
from django.apps import AppConfig
APP_NAME = 'vsemionov.notes.api'
APP_VERSION = '0.2'
class ApiConfig(AppConfig):
name = 'api'
| mit | Python |
492005db9a7c34b2648de8b7335bdbdd18ffb13b | Update setup.py with release version. | google/gps_building_blocks,google/gps_building_blocks | py/setup.py | py/setup.py | # Lint as: python3
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Config file for distributing package via Pypi server."""
import setuptools
# It is assumed that this file will moved to gps_building_block/py/setup.py,
# while the README resides at gps_building_blocks/README.md.
with open("../README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="gps-building-blocks",
version="1.0.0",
author="gPS Team",
author_email="no-reply@google.com",
description="Modules and tools useful for use with advanced data solutions on Google Ads, Google Marketing Platform and Google Cloud.",
long_description=long_description,
long_description_tpye="text/markdown",
url="https://github.com/google/gps_building_blocks",
license="Apache Software License",
packages=setuptools.find_packages(),
install_requires=[
"absl-py==0.9.0",
"google-api-core==1.17.0",
"google-api-python-client==1.9.1",
"google-auth==1.16.0",
"google-cloud-bigquery==1.22.0",
"google-cloud-storage==1.28.1",
"requests==2.23.0",
"dataclasses; python_version<'3.7'"
],
classifiers=[
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Internet",
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Operating System :: OS Independent",
],
)
| # Lint as: python3
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Config file for distributing package via Pypi server."""
import setuptools
# It is assumed that this file will moved to gps_building_block/py/setup.py,
# while the README resides at gps_building_blocks/README.md.
with open("../README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="gps-building-blocks",
version="0.1.12",
author="gPS Team",
author_email="no-reply@google.com",
description="Modules and tools useful for use with advanced data solutions on Google Ads, Google Marketing Platform and Google Cloud.",
long_description=long_description,
long_description_tpye="text/markdown",
url="https://github.com/google/gps_building_blocks",
license="Apache Software License",
packages=setuptools.find_packages(),
install_requires=[
"absl-py==0.9.0",
"google-api-core==1.17.0",
"google-api-python-client==1.9.1",
"google-auth==1.16.0",
"google-cloud-bigquery==1.22.0",
"google-cloud-storage==1.28.1",
"requests==2.23.0",
"dataclasses; python_version<'3.7'"
],
classifiers=[
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Internet",
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Operating System :: OS Independent",
],
)
| apache-2.0 | Python |
d31d767ec4c4452e8a1d5f9dd896ade19e4ac645 | Fix tests | martmists/asynctwitch | run_test.py | run_test.py | import asynctwitch as at
class Bot(at.CommandBot, at.RankedBot):
pass
bot = Bot(
user='justinfan100' # read-only client
)
@bot.command("test", desc="Some test command")
async def test(m, arg1:int):
pass
bot.add_rank("test rank", points=10)
@bot.override
async def raw_event(data):
print(data)
@bot.override
async def event_roomstate(channel, tags):
bot.stop(exit=True)
print('Failed to exit!')
bot.start() | import asynctwitch as at
class Bot(at.CommandBot, at.RankedBot):
pass
bot = Bot(
user='justinfan100' # read-only client
)
@bot.command("test", desc="Some test command")
async def test(m, arg1:int):
pass
bot.add_rank("test rank", points=10)
@bot.override
async def raw_event(data):
print(data)
@bot.override
async def event_roomstate(tags):
bot.stop(exit=True)
print('Failed to exit!')
bot.start() | bsd-3-clause | Python |
38a086d2c5ebf73f7ad0108def2304262a2e0452 | Add trailing comma | pinax/phileo,pinax/pinax-likes,pinax/phileo | runtests.py | runtests.py | #!/usr/bin/env python
import os
import sys
import django
from django.conf import settings
DEFAULT_SETTINGS = dict(
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"pinax.likes",
"pinax.likes.tests"
],
MIDDLEWARE_CLASSES=[],
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
},
SITE_ID=1,
ROOT_URLCONF="pinax.likes.tests.urls",
SECRET_KEY="notasecret",
PINAX_LIKES_LIKABLE_MODELS={
"auth.User": {
"like_text_on": "unlike",
"css_class_on": "fa-heart",
"like_text_off": "like",
"css_class_off": "fa-heart-o",
"allowed": lambda user, obj: True
},
"tests.Demo": {
"like_text_on": "unlike",
"css_class_on": "fa-heart",
"like_text_off": "like",
"css_class_off": "fa-heart-o"
}
},
AUTHENTICATION_BACKENDS=[
"pinax.likes.auth_backends.CanLikeBackend"
],
)
def runtests(*test_args):
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)
django.setup()
parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)
try:
from django.test.runner import DiscoverRunner
runner_class = DiscoverRunner
test_args = ["pinax.likes.tests"]
except ImportError:
from django.test.simple import DjangoTestSuiteRunner
runner_class = DjangoTestSuiteRunner
test_args = ["tests"]
failures = runner_class(verbosity=1, interactive=True, failfast=False).run_tests(test_args)
sys.exit(failures)
if __name__ == "__main__":
runtests(*sys.argv[1:])
| #!/usr/bin/env python
import os
import sys
import django
from django.conf import settings
DEFAULT_SETTINGS = dict(
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"pinax.likes",
"pinax.likes.tests"
],
MIDDLEWARE_CLASSES=[],
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
},
SITE_ID=1,
ROOT_URLCONF="pinax.likes.tests.urls",
SECRET_KEY="notasecret",
PINAX_LIKES_LIKABLE_MODELS={
"auth.User": {
"like_text_on": "unlike",
"css_class_on": "fa-heart",
"like_text_off": "like",
"css_class_off": "fa-heart-o",
"allowed": lambda user, obj: True
},
"tests.Demo": {
"like_text_on": "unlike",
"css_class_on": "fa-heart",
"like_text_off": "like",
"css_class_off": "fa-heart-o"
}
},
AUTHENTICATION_BACKENDS=[
"pinax.likes.auth_backends.CanLikeBackend"
]
)
def runtests(*test_args):
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)
django.setup()
parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)
try:
from django.test.runner import DiscoverRunner
runner_class = DiscoverRunner
test_args = ["pinax.likes.tests"]
except ImportError:
from django.test.simple import DjangoTestSuiteRunner
runner_class = DjangoTestSuiteRunner
test_args = ["tests"]
failures = runner_class(verbosity=1, interactive=True, failfast=False).run_tests(test_args)
sys.exit(failures)
if __name__ == "__main__":
runtests(*sys.argv[1:])
| mit | Python |
cc626bef4bb9ad4888362476a3ce9f92154f7d53 | Resolve #74 -- Use result.get instastad of ready | KristianOellegaard/django-health-check,KristianOellegaard/django-health-check | health_check/contrib/celery/plugin_health_check.py | health_check/contrib/celery/plugin_health_check.py | # -*- coding: utf-8 -*-
from datetime import datetime, timedelta
from django.conf import settings
from health_check.backends.base import (
BaseHealthCheckBackend, ServiceUnavailable,
ServiceReturnedUnexpectedResult)
from health_check.plugins import plugin_dir
from .tasks import add
class CeleryHealthCheck(BaseHealthCheckBackend):
def check_status(self):
timeout = getattr(settings, 'HEALTHCHECK_CELERY_TIMEOUT', 3)
try:
result = add.apply_async(
args=[4, 4],
expires=datetime.now() + timedelta(seconds=timeout)
)
result.get(timeout=timeout)
if result.result != 8:
self.add_error(ServiceReturnedUnexpectedResult("Celery return wrong result"))
except IOError as e:
self.add_error(ServiceUnavailable("IOError"), e)
except BaseException as e:
self.add_error(ServiceUnavailable("Unknown error"), e)
plugin_dir.register(CeleryHealthCheck)
| # -*- coding: utf-8 -*-
from datetime import datetime, timedelta
from time import sleep
from django.conf import settings
from health_check.backends.base import (
BaseHealthCheckBackend, ServiceUnavailable
)
from health_check.plugins import plugin_dir
from .tasks import add
class CeleryHealthCheck(BaseHealthCheckBackend):
def check_status(self):
timeout = getattr(settings, 'HEALTHCHECK_CELERY_TIMEOUT', 3)
try:
result = add.apply_async(
args=[4, 4],
expires=datetime.now() + timedelta(seconds=timeout)
)
now = datetime.now()
while (now + timedelta(seconds=3)) > datetime.now():
print(" checking....")
if result.ready():
try:
result.forget()
except NotImplementedError:
pass
return True
sleep(0.5)
except IOError:
raise ServiceUnavailable("IOError")
except:
raise ServiceUnavailable("Unknown error")
raise ServiceUnavailable("Unknown error")
plugin_dir.register(CeleryHealthCheck)
| mit | Python |
f641c4be6e88aac1e1968ca8f07c5294d4dfe6fa | Bump version | initios/factura-pdf | facturapdf/__about__.py | facturapdf/__about__.py | __title__ = 'facturapdf'
__summary__ = 'Create PDF invoice according to Spanish regulations.'
__version__ = '0.0.3'
__license__ = 'BSD 3-Clause License'
__uri__ = 'https://github.com/initios/factura-pdf'
__author__ = 'Carlos Goce'
__email__ = 'cgonzalez@initios.com'
| __title__ = 'facturapdf'
__summary__ = 'Create PDF invoice according to Spanish regulations.'
__version__ = '0.0.2'
__license__ = 'BSD 3-Clause License'
__uri__ = 'https://github.com/initios/factura-pdf'
__author__ = 'Carlos Goce'
__email__ = 'cgonzalez@initios.com'
| bsd-3-clause | Python |
1e3199618f55be86fa5e4259d1c6e4a7074e57ca | Update environment.py | RaulAlvarez/selenide | features/environment.py | features/environment.py | """
Copyright 2017 Raul Alvarez
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import Selenium
def before_all(context):
runner = Selenium.Selenium()
context.runner = runner
def after_all(context):
context.runner.quit()
| """
Copyright 2017 Raul Alvarez
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""import Selenium
def before_all(context):
runner = Selenium.Selenium()
context.runner = runner
def after_all(context):
context.runner.quit()
| apache-2.0 | Python |
576ea74646935c00e051a46244b8f56165710df0 | Add multicast send | eriol/circuits,treemo/circuits,treemo/circuits,treemo/circuits,eriol/circuits,nizox/circuits,eriol/circuits | circuits/node/server.py | circuits/node/server.py | # Module: server
# Date: ...
# Author: ...
"""Server
...
"""
from circuits.net.sockets import TCPServer
from circuits import handler, BaseComponent
from .protocol import Protocol
class Server(BaseComponent):
"""Server
...
"""
channel = 'node'
__protocol = {}
def __init__(self, bind, channel=channel, **kwargs):
super(Server, self).__init__(channel=channel, **kwargs)
self.server = TCPServer(bind, channel=self.channel, **kwargs)
self.server.register(self)
self.__receive_event_firewall = kwargs.get(
'receive_event_firewall',
None
)
self.__send_event_firewall = kwargs.get(
'send_event_firewall',
None
)
def send(self, event, sock):
return self.__protocol[sock].send(event)
def send_to(self, event, socks):
for sock in socks:
self.send(event, sock)
def send_all(self, event):
for sock in self.__protocol:
self.__protocol[sock].send(event)
@handler('read')
def _on_read(self, sock, data):
self.__protocol[sock].add_buffer(data)
@property
def host(self):
if hasattr(self, 'server'):
return self.server.host
@property
def port(self):
if hasattr(self, 'server'):
return self.server.port
@handler('connect')
def __connect_peer(self, sock, host, port):
self.__protocol[sock] = Protocol(
sock=sock,
server=self.server,
receive_event_firewall=self.__receive_event_firewall,
send_event_firewall=self.__send_event_firewall
).register(self)
@handler('disconnect')
def __disconnect_peer(self, sock):
for s in self.__protocol.copy():
try:
s.getpeername()
except:
del(self.__protocol[s])
| # Module: server
# Date: ...
# Author: ...
"""Server
...
"""
from circuits.net.sockets import TCPServer
from circuits import handler, BaseComponent
from .protocol import Protocol
class Server(BaseComponent):
"""Server
...
"""
channel = 'node'
__protocol = {}
def __init__(self, bind, channel=channel, **kwargs):
super(Server, self).__init__(channel=channel, **kwargs)
self.server = TCPServer(bind, channel=self.channel, **kwargs)
self.server.register(self)
self.__receive_event_firewall = kwargs.get(
'receive_event_firewall',
None
)
self.__send_event_firewall = kwargs.get(
'send_event_firewall',
None
)
def send(self, event, sock):
return self.__protocol[sock].send(event)
def send_all(self, event):
for sock in self.__protocol:
self.__protocol[sock].send(event)
@handler('read')
def _on_read(self, sock, data):
self.__protocol[sock].add_buffer(data)
@property
def host(self):
if hasattr(self, 'server'):
return self.server.host
@property
def port(self):
if hasattr(self, 'server'):
return self.server.port
@handler('connect')
def __connect_peer(self, sock, host, port):
self.__protocol[sock] = Protocol(
sock=sock,
server=self.server,
receive_event_firewall=self.__receive_event_firewall,
send_event_firewall=self.__send_event_firewall
).register(self)
@handler('disconnect')
def __disconnect_peer(self, sock):
for s in self.__protocol.copy():
try:
s.getpeername()
except:
del(self.__protocol[s])
| mit | Python |
8c68031928f54d38c92308504bc93bf61ead57f5 | Update clashcallerbot_reply.py added get list of messages older than current datetime, updated outline | JoseALermaIII/clashcallerbot-reddit,JoseALermaIII/clashcallerbot-reddit | clashcallerbot_reply.py | clashcallerbot_reply.py | #! python3
# -*- coding: utf-8 -*-
"""Checks messages in database and sends PM if expiration time passed.
This module checks messages saved in a MySQL-compatible database and sends a reminder
via PM if the expiration time has passed. If so, the message is removed from the
database.
"""
import praw
import praw.exceptions
import logging.config
import datetime
import clashcallerbot_database as db
# Logger
logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
logging.raiseExceptions = True # Production mode if False (no console sys.stderr output)
logger = logging.getLogger('reply')
# Generate reddit instance
reddit = praw.Reddit('clashcallerreply') # Section name in praw.ini
subreddit = reddit.subreddit('ClashCallerBot') # Limit scope for testing purposes
def main():
while True:
# Get list of messages older than current datetime
now = datetime.datetime.now(datetime.timezone.utc)
messages = db.get_messages(now)
if not messages:
continue
# TODO: Send reminder PM
# TODO: Delete message from database
# If run directly, instead of imported as a module, run main():
if __name__ == '__main__':
main()
| #! python3
# -*- coding: utf-8 -*-
"""Checks messages in database and sends PM if expiration time passed.
This module checks messages saved in a MySQL-compatible database and sends a reminder
via PM if the expiration time has passed. If so, the message is removed from the
database.
"""
import praw
import praw.exceptions
import logging.config
import datetime
import clashcallerbot_database as db
# Logger
logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
logging.raiseExceptions = True # Production mode if False (no console sys.stderr output)
logger = logging.getLogger('reply')
# Generate reddit instance
reddit = praw.Reddit('clashcallerreply') # Section name in praw.ini
subreddit = reddit.subreddit('ClashCallerBot') # Limit scope for testing purposes
def main():
while True:
# TODO: Get list of messages ordered by expiration date (in MySQL)
# TODO: Compare each message expiration datetime to current datetime (in MySQL?)
# TODO: If current datetime is after expiration datetime, send PM
# TODO: Delete message from database
pass
# If run directly, instead of imported as a module, run main():
if __name__ == '__main__':
main()
| mit | Python |
2cbae4650422f7982ef50e564e9e27e7fd294be8 | Add ability to nix product to admin | Ritsyy/fjord,lgp171188/fjord,mozilla/fjord,DESHRAJ/fjord,hoosteeno/fjord,DESHRAJ/fjord,Ritsyy/fjord,hoosteeno/fjord,rlr/fjord,staranjeet/fjord,lgp171188/fjord,Ritsyy/fjord,staranjeet/fjord,hoosteeno/fjord,lgp171188/fjord,rlr/fjord,staranjeet/fjord,mozilla/fjord,mozilla/fjord,mozilla/fjord,lgp171188/fjord,Ritsyy/fjord,rlr/fjord,DESHRAJ/fjord,rlr/fjord,hoosteeno/fjord,staranjeet/fjord | fjord/feedback/admin.py | fjord/feedback/admin.py | from django.contrib import admin
from django.core.exceptions import PermissionDenied
from fjord.feedback.models import Product, Response
class ProductAdmin(admin.ModelAdmin):
list_display = (
'id',
'enabled',
'on_dashboard',
'display_name',
'db_name',
'translation_system',
'notes',
'slug')
list_filter = ('enabled', 'on_dashboard')
class EmptyFriendlyAVFLF(admin.AllValuesFieldListFilter):
def choices(self, cl):
"""Displays empty string as <Empty>
This makes it possible to choose Empty in the filter
list. Otherwise empty strings display as '' and don't get any
height and thus aren't selectable.
"""
for choice in super(EmptyFriendlyAVFLF, self).choices(cl):
if choice.get('display') == '':
choice['display'] = '<Empty>'
yield choice
class ResponseFeedbackAdmin(admin.ModelAdmin):
list_display = ('created', 'product', 'channel', 'version', 'happy',
'description', 'user_agent', 'locale')
list_filter = ('happy', ('product', EmptyFriendlyAVFLF),
('locale', EmptyFriendlyAVFLF))
search_fields = ('description',)
actions = ['nix_product']
list_per_page = 200
def nix_product(self, request, queryset):
ret = queryset.update(product=u'')
self.message_user(request, '%s responses updated.' % ret)
nix_product.short_description = u'Remove product for selected responses'
def queryset(self, request):
# Note: This ignores the super() queryset and uses the
# uncached manager.
return Response.uncached.all()
def has_add_permission(self, request, obj=None):
# Prevent anyone from adding feedback in the admin.
return False
def change_view(self, request, *args, **kwargs):
# We don't want anyone (including superusers) to change
# feedback. It's either keep it or delete it.
#
# That's sort of difficult with Django without writing a bunch
# of stuff, so I'm lazily preventing POST here.
#
# TODO: Make this better, but push off any changes until other
# non-superuser people have access to this view and it becomes
# a relevant issue.
if request.method == 'POST':
raise PermissionDenied()
return super(ResponseFeedbackAdmin, self).change_view(
request, *args, **kwargs)
admin.site.register(Product, ProductAdmin)
admin.site.register(Response, ResponseFeedbackAdmin)
| from django.contrib import admin
from django.core.exceptions import PermissionDenied
from fjord.feedback.models import Product, Response
class ProductAdmin(admin.ModelAdmin):
list_display = (
'id',
'enabled',
'on_dashboard',
'display_name',
'db_name',
'translation_system',
'notes',
'slug')
list_filter = ('enabled', 'on_dashboard')
class EmptyFriendlyAVFLF(admin.AllValuesFieldListFilter):
def choices(self, cl):
"""Displays empty string as <Empty>
This makes it possible to choose Empty in the filter
list. Otherwise empty strings display as '' and don't get any
height and thus aren't selectable.
"""
for choice in super(EmptyFriendlyAVFLF, self).choices(cl):
if choice.get('display') == '':
choice['display'] = '<Empty>'
yield choice
class ResponseFeedbackAdmin(admin.ModelAdmin):
list_display = ('created', 'product', 'channel', 'version', 'happy',
'description', 'user_agent', 'locale')
list_filter = ('happy', ('product', EmptyFriendlyAVFLF),
('locale', EmptyFriendlyAVFLF))
search_fields = ('description',)
def queryset(self, request):
# Note: This ignores the super() queryset and uses the
# uncached manager.
return Response.uncached.all()
def has_add_permission(self, request, obj=None):
# Prevent anyone from adding feedback in the admin.
return False
def change_view(self, request, *args, **kwargs):
# We don't want anyone (including superusers) to change
# feedback. It's either keep it or delete it.
#
# That's sort of difficult with Django without writing a bunch
# of stuff, so I'm lazily preventing POST here.
#
# TODO: Make this better, but push off any changes until other
# non-superuser people have access to this view and it becomes
# a relevant issue.
if request.method == 'POST':
raise PermissionDenied()
return super(ResponseFeedbackAdmin, self).change_view(
request, *args, **kwargs)
admin.site.register(Product, ProductAdmin)
admin.site.register(Response, ResponseFeedbackAdmin)
| bsd-3-clause | Python |
e19e2d69baabac3adedfae4e7a8c6ef5bb3d6f53 | Fix alembic script | EIREXE/SpaceDock,EIREXE/SpaceDock,EIREXE/SpaceDock,EIREXE/SpaceDock | alembic/versions/4e0500347ce7_add_multigame_tables.py | alembic/versions/4e0500347ce7_add_multigame_tables.py | """add multigame tables
Revision ID: 4e0500347ce7
Revises: 29344aa34d9
Create Date: 2016-04-05 23:51:58.647657
"""
# revision identifiers, used by Alembic.
revision = '4e0500347ce7'
down_revision = '29344aa34d9'
from alembic import op
import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('gameversion', sa.Column('game_id', sa.Integer(), nullable=True))
op.create_foreign_key('gameversion_game_id_fkey', 'gameversion', 'game', ['game_id'], ['id'])
op.add_column('mod', sa.Column('game_id', sa.Integer(), nullable=True))
op.create_foreign_key('mod_game_id_fkey', 'mod', 'game', ['game_id'], ['id'])
op.add_column('modlist', sa.Column('game_id', sa.Integer(), nullable=True))
op.create_foreign_key('modlist_game_id_fkey', 'modlist', 'game', ['game_id'], ['id'])
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('modlist_game_id_fkey', 'modlist', type_='foreignkey')
op.drop_column('modlist', 'game_id')
op.drop_constraint('mod_game_id_fkey', 'mod', type_='foreignkey')
op.drop_column('mod', 'game_id')
op.drop_constraint('gameversion_game_id_fkey', 'gameversion', type_='foreignkey')
op.drop_column('gameversion', 'game_id')
### end Alembic commands ###
| """add multigame tables
Revision ID: 4e0500347ce7
Revises: 29344aa34d9
Create Date: 2016-03-30 12:26:36.632566
"""
# revision identifiers, used by Alembic.
revision = '4e0500347ce7'
down_revision = '29344aa34d9'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table(
'publisher',
sa.Column('id', sa.Integer, primary_key=True,autoincrement=True),
sa.Column('name', sa.String(50), nullable=False),
sa.Column('description', sa.Unicode(200)),
)
op.create_table(
'game',
sa.Column('id', sa.Integer, primary_key=True,autoincrement=True),
sa.Column('name', sa.String(50), nullable=False),
sa.Column('description', sa.Unicode(200)),
sa.Column('theme', sa.Integer, nullable=True),
sa.Column('publisher', sa.Integer, nullable=False),
)
op.create_table(
'theme',
sa.Column('id', sa.Integer, primary_key=True,autoincrement=True),
sa.Column('name', sa.String(50), nullable=False),
sa.Column('css', sa.String(50), nullable=False),
sa.Column('description', sa.Unicode(200)),
)
op.add_column('gameversion', sa.Column('game', sa.Integer, nullable=False))
op.add_column('mod', sa.Column('game', sa.Integer, nullable=False))
def downgrade():
op.drop_table('publisher')
op.drop_table('game')
op.drop_table('theme')
op.drop_column('gameversion', 'game')
op.drop_column('mod', 'game')
| mit | Python |
bd98a1b1119b34a5435855478d733ca582ebcf0c | Update version to dev | simplecrypto/powerpool,nickgzzjr/powerpool,simplecrypto/powerpool,cinnamoncoin/powerpool,cinnamoncoin/powerpool,nickgzzjr/powerpool | powerpool/__init__.py | powerpool/__init__.py | __version__ = "0.6.3-dev"
__version_info__ = (0, 6, 3)
| __version__ = "0.6.2"
__version_info__ = (0, 6, 2)
| bsd-2-clause | Python |
ff99addf5ac6589b4ee2c53ef1debf4e9c07b47d | Bump version 0.2 Stable | fulfilio/nereid-catalog,prakashpp/nereid-catalog,priyankarani/nereid-catalog | __tryton__.py | __tryton__.py | #This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
{
'name': 'Nereid Catalog',
'version': '2.0.0.2',
'author': 'Openlabs Technologies & Consulting (P) LTD',
'email': 'info@openlabs.co.in',
'website': 'http://www.openlabs.co.in/',
'description': '''Nereid Catalog''',
'depends': [
'product',
'nereid',
],
'xml': [
'product.xml',
'urls.xml',
],
'translation': [
],
}
| #This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
{
'name': 'Nereid Catalog',
'version': '2.0.0.1',
'author': 'Openlabs Technologies & Consulting (P) LTD',
'email': 'info@openlabs.co.in',
'website': 'http://www.openlabs.co.in/',
'description': '''Nereid Catalog''',
'depends': [
'product',
'nereid',
],
'xml': [
'product.xml',
'urls.xml',
],
'translation': [
],
}
| bsd-3-clause | Python |
d826e54996bc504d245286b50f7ab5671f1999ae | Update solution.py | lilsweetcaligula/Algorithms,lilsweetcaligula/Algorithms,lilsweetcaligula/Algorithms | data_structures/linked_list/problems/find_pattern_in_linked_list/py/solution.py | data_structures/linked_list/problems/find_pattern_in_linked_list/py/solution.py | import LinkedList
# Problem description: Find a string pattern represented as a linked list in a target linked list.
# Solution time complexity: O(n^2)
# Comments: A brute force solution w/o any optimizations. Simply traverse a list looking for the pattern.
# If the node traversing the "pattern" list ever reaches the end (i.e. pnode == null), it is in
# the list. The case where a pnode may be equal to null due to the pattern being null, is ruled
# out by a test at the beginning of the function.
# Linked List Node inside the LinkedList module is defined as:
#
# class Node:
# def __init__(self, val, nxt=None):
# self.val = val
# self.nxt = nxt
#
def FindPatternInLinkedList(head: LinkedList.Node, pattern: LinkedList.Node) -> int:
if head == None or pattern == None:
return -1
index = 0
tslow = head
pnode = pattern
while tslow != None:
if tslow.val == pattern.val:
tfast = tslow
pnode = pattern
while tfast != None and pnode != None:
if tfast.val == pnode.val:
tfast = tfast.nxt
pnode = pnode.nxt
else:
break
if pnode == None:
return index
tslow = tslow.nxt
index += 1
return -1
| import LinkedList
# Problem description: Find a pattern represented as a linked list in a target linked list.
# Solution time complexity: O(n^2)
# Comments: A brute force solution w/o any optimizations. Simply traverse a list looking for the pattern.
# If the node traversing the "pattern" list ever reaches the end (i.e. pnode == null), it is in
# the list. The case where a pnode may be equal to null due to the pattern being null, is ruled
# out by a test at the beginning of the function.
# Linked List Node inside the LinkedList module is defined as:
#
# class Node:
# def __init__(self, val, nxt=None):
# self.val = val
# self.nxt = nxt
#
def FindPatternInLinkedList(head: LinkedList.Node, pattern: LinkedList.Node) -> int:
if head == None or pattern == None:
return -1
index = 0
tslow = head
pnode = pattern
while tslow != None:
if tslow.val == pattern.val:
tfast = tslow
pnode = pattern
while tfast != None and pnode != None:
if tfast.val == pnode.val:
tfast = tfast.nxt
pnode = pnode.nxt
else:
break
if pnode == None:
return index
tslow = tslow.nxt
index += 1
return -1
| mit | Python |
7c527f486e2e129861915f73e0625ec00388e15e | Fix failing MPI tests | joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue | test/hoomd_script/test_multiple_contexts.py | test/hoomd_script/test_multiple_contexts.py | # -*- coding: iso-8859-1 -*-
from hoomd_script import *
import hoomd_script;
context.initialize()
import unittest
import os
# unit test to run a simple polymer system with pair and bond potentials
class multi_context(unittest.TestCase):
def test_run(self):
self.c1 = context.SimulationContext()
self.c2 = context.SimulationContext()
with self.c1:
init.create_random(N=2000, phi_p=0.2)
lj = pair.lj(r_cut=3.0)
lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0)
integrate.mode_standard(dt=0.005)
integrate.nvt(group=group.all(), T=1.2, tau=0.5)
with self.c2:
init.create_random(N=1000, phi_p=0.02)
lj = pair.lj(r_cut=3.0)
lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0)
integrate.mode_standard(dt=0.005)
integrate.nvt(group=group.all(), T=1.2, tau=0.5)
with self.c1:
run(10)
with self.c2:
run(10)
if __name__ == '__main__':
unittest.main(argv = ['test.py', '-v'])
| # -*- coding: iso-8859-1 -*-
from hoomd_script import *
import hoomd_script;
context.initialize()
import unittest
import os
# unit test to run a simple polymer system with pair and bond potentials
class multi_context(unittest.TestCase):
def test_run(self):
self.c1 = context.SimulationContext()
self.c2 = context.SimulationContext()
with self.c1:
init.create_random(N=500, phi_p=0.2)
lj = pair.lj(r_cut=3.0)
lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0)
integrate.mode_standard(dt=0.005)
integrate.nvt(group=group.all(), T=1.2, tau=0.5)
with self.c2:
init.create_random(N=200, phi_p=0.02)
lj = pair.lj(r_cut=3.0)
lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0)
integrate.mode_standard(dt=0.005)
integrate.nvt(group=group.all(), T=1.2, tau=0.5)
with self.c1:
run(10)
with self.c2:
run(10)
if __name__ == '__main__':
unittest.main(argv = ['test.py', '-v'])
| bsd-3-clause | Python |
145c31a283bb458bdce72169ea16f07040236ee5 | add comment about settings.py | opencorato/represent-boundaries,datamade/represent-boundaries,opencorato/represent-boundaries,datamade/represent-boundaries,datamade/represent-boundaries,opencorato/represent-boundaries | settings.py | settings.py | """
To run `django-admin.py syncdb --settings settings --noinput` before testing.
"""
SECRET_KEY = 'x'
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'travis_ci_test',
}
}
INSTALLED_APPS=(
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.gis',
'boundaries',
)
| SECRET_KEY = 'x'
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'travis_ci_test',
}
}
INSTALLED_APPS=(
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.gis',
'boundaries',
)
| mit | Python |
417ab5241c852cdcd072143bc2444f20f2117623 | Update capture profiler to new spec of providing board instead of string. | kobejohn/PQHelper | tests/execution_profiles/capture_profile.py | tests/execution_profiles/capture_profile.py | import cProfile
from pqhelper import capture
def main():
cProfile.run('test_solution(catapult)')
def test_solution(board_string):
board = capture.Board(board_string)
print capture.capture(board)
skeleton = '''
..*..*..
.gm..mg.
.ms..sm.
.rs..sr.
.ggmmgg.
.rsggsr.
.rsrrsr.
ssgssgss'''
giant_rat = '''
...mm...
..mrym..
.mgyrgm.
mygrygym
ryxssxyr
rxgbbgxr
xygssgyx
rybssbyr'''
griffon = '''
.r..s...
.b.sy...
.b.yys..
.r.yxg.g
.g.x*b.r
.g.xxb.r
rybyxygy
ygyxybyr'''
catapult = '''
........
........
..mbgm..
.mxgbrm.
my*gb*gm
yrrxrxxg
ymxyyrmg
ssxssrss'''
easy = '''
........
........
........
........
.......x
....xx.r
....rr.r
..rryyry'''
if __name__ == '__main__':
main() | import cProfile
from pqhelper import capture
def main():
cProfile.run('test_solution(catapult)')
def test_solution(board_string):
print capture.capture(board_string)
skeleton = '''
..*..*..
.gm..mg.
.ms..sm.
.rs..sr.
.ggmmgg.
.rsggsr.
.rsrrsr.
ssgssgss'''
giant_rat = '''
...mm...
..mrym..
.mgyrgm.
mygrygym
ryxssxyr
rxgbbgxr
xygssgyx
rybssbyr'''
griffon = '''
.r..s...
.b.sy...
.b.yys..
.r.yxg.g
.g.x*b.r
.g.xxb.r
rybyxygy
ygyxybyr'''
catapult = '''
........
........
..mbgm..
.mxgbrm.
my*gb*gm
yrrxrxxg
ymxyyrmg
ssxssrss'''
easy = '''
........
........
........
........
.......x
....xx.r
....rr.r
..rryyry'''
if __name__ == '__main__':
main() | mit | Python |
a12d61e9a9b85c436d5b21b39862497b7e3ed903 | update tpp.py for gen3 | sc0tt/Reddit-Live-Console | tpp.py | tpp.py | #This script will show updates to the Twitch Plays Pokemon live feed on reddit.
#You can only show important updates by passing the --important flag when you run the script
#This could be easily adapted for other live feeds (or totally generic) but for now
#it is hardcoded for the TPP feed.
#python-requests is required to run this.
#Install using:
#pip install requests
from __future__ import print_function
import requests
import time
import argparse
import sys
_parser = argparse.ArgumentParser(description="Live Twitch Plays Pokemon updates in your console.")
_parser.add_argument("--important", action="store_true")
_args = _parser.parse_args()
_api_url = "http://api.reddit.com/live/nawsz3vn7ui6hdsgciytwcxadi"
_headers = {"User-Agent": "TTPConsole/1.1 by sc00ty"}
_timeout = 60 #1 Minute
_last_id = ""
while True:
try:
#Request the JSON data for the live feed
payload = {"before": _last_id}
feed = requests.get(_api_url, params=payload, headers=_headers).json()
#Iterate backwards through the list, making it so items are shown chronologically
for feed_item in feed["data"]["children"][::-1]:
#Store the last seen id
_last_id = feed_item["data"]["name"]
body_text = feed_item["data"]["body"]
#If all text should be shown OR only important stuff, and this is important... show the update!
if not _args.important or ("**" in body_text and _args.important):
print("%s\n" % (body_text,))
#Progress towards next update.
for i in range (0, _timeout):
print("Checking for update in %ss.\r" % (_timeout - i), end="")
sys.stdout.flush()
time.sleep(1)
except KeyboardInterrupt:
break
except Exception:
print("Encountered an error while retrieving data. Exiting...")
| #This script will show updates to the Twitch Plays Pokemon live feed on reddit.
#You can only show important updates by passing the --important flag when you run the script
#This could be easily adapted for other live feeds (or totally generic) but for now
#it is hardcoded for the TPP feed.
#python-requests is required to run this.
#Install using:
#pip install requests
from __future__ import print_function
import requests
import time
import argparse
import sys
_parser = argparse.ArgumentParser(description="Live Twitch Plays Pokemon updates in your console.")
_parser.add_argument("--important", action="store_true")
_args = _parser.parse_args()
_api_url = "http://api.reddit.com/live/m5n42gvbpyi6hdisciytwamw3a"
_headers = {"User-Agent": "TTPConsole/1.1 by sc00ty"}
_timeout = 60 #1 Minute
_last_id = ""
while True:
try:
#Request the JSON data for the live feed
payload = {"before": _last_id}
feed = requests.get(_api_url, params=payload, headers=_headers).json()
#Iterate backwards through the list, making it so items are shown chronologically
for feed_item in feed["data"]["children"][::-1]:
#Store the last seen id
_last_id = feed_item["data"]["name"]
body_text = feed_item["data"]["body"]
#If all text should be shown OR only important stuff, and this is important... show the update!
if not _args.important or ("**" in body_text and _args.important):
print("%s\n" % (body_text,))
#Progress towards next update.
for i in range (0, _timeout):
print("Checking for update in %ss.\r" % (_timeout - i), end="")
sys.stdout.flush()
time.sleep(1)
except KeyboardInterrupt:
break
except Exception:
print("Encountered an error while retrieving data. Exiting...")
| mit | Python |
c81eb510c72511c1f692f02f7bb63ef4caa51d27 | Add management functions for migration | mfitzp/smrtr,mfitzp/smrtr | apps/concept/management/commands/update_concept_totals.py | apps/concept/management/commands/update_concept_totals.py | from optparse import make_option
import sys
from django.core.management.base import BaseCommand
from concept.models import Concept
class Command(BaseCommand):
args = ""
help = "Update concept total_question counts (post db import)"
def handle(self, *args, **options):
for concept in Concept.objects.all():
concept.total_questions = concept.question_set.count()
concept.save()
| from optparse import make_option
import sys
from django.core.management.base import BaseCommand
from education.models import Concept
class Command(BaseCommand):
args = ""
help = "Update concept total_question counts (post db import)"
def handle(self, *args, **options):
for concept in Concept.objects.all():
concept.total_questions = concept.question_set.count()
concept.save()
| bsd-3-clause | Python |
6a39a514ae82f412c107dd87944cdb17b6a9d036 | remove isinstance assert in test_remove_site_packages_64bit | MSLNZ/msl-loadlib,MSLNZ/msl-loadlib,MSLNZ/msl-loadlib,MSLNZ/msl-loadlib,MSLNZ/msl-loadlib | tests/test_server32_remove_site_packages.py | tests/test_server32_remove_site_packages.py | import os
import sys
try:
import pytest
except ImportError: # the 32-bit server does not need pytest installed
class Mark(object):
@staticmethod
def skipif(condition, reason=None):
def func(function):
return function
return func
class pytest(object):
mark = Mark
from msl.loadlib import Server32, Client64, IS_MAC
from msl.examples.loadlib import EXAMPLES_DIR
class Site32(Server32):
def __init__(self, host, port, **kwargs):
super(Site32, self).__init__(
os.path.join(kwargs['ex_dir'], 'cpp_lib32'),
'cdll', host, port
)
def remove(self):
return self.remove_site_packages_64bit()
@staticmethod
def contains(path):
return path in sys.path
class Site64(Client64):
def __init__(self):
super(Site64, self).__init__(__file__, ex_dir=EXAMPLES_DIR)
def remove(self):
return self.request32('remove')
def contains(self, path):
return self.request32('contains', path)
@pytest.mark.skipif(IS_MAC, reason='the 32-bit server for macOS does not exist')
def test_remove_site_packages_64bit():
s = Site64()
path = s.remove()
assert path in sys.path
assert not s.contains(path)
| import os
import sys
try:
import pytest
except ImportError: # the 32-bit server does not need pytest installed
class Mark(object):
@staticmethod
def skipif(condition, reason=None):
def func(function):
return function
return func
class pytest(object):
mark = Mark
from msl.loadlib import Server32, Client64, IS_MAC
from msl.examples.loadlib import EXAMPLES_DIR
class Site32(Server32):
def __init__(self, host, port, **kwargs):
super(Site32, self).__init__(
os.path.join(kwargs['ex_dir'], 'cpp_lib32'),
'cdll', host, port
)
def remove(self):
return self.remove_site_packages_64bit()
@staticmethod
def contains(path):
return path in sys.path
class Site64(Client64):
def __init__(self):
super(Site64, self).__init__(__file__, ex_dir=EXAMPLES_DIR)
def remove(self):
return self.request32('remove')
def contains(self, path):
return self.request32('contains', path)
@pytest.mark.skipif(IS_MAC, reason='the 32-bit server for macOS does not exist')
def test_remove_site_packages_64bit():
s = Site64()
path = s.remove()
assert isinstance(path, str)
assert path in sys.path
assert not s.contains(path)
| mit | Python |
79ef0fe21b136b80889a8e6e06339074ac73a1f1 | Comment out section | mattstibbs/blockbuster-server,mattstibbs/blockbuster-server | run.py | run.py | __author__ = 'matt'
# import datetime
import blockbuster
# blockbuster.app.debug = blockbuster.config.debug_mode
#
# blockbuster.bb_logging.logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
# blockbuster.bb_logging.logger.info("@@@@@@@@@@@@@@@@@@ BlockBuster " + blockbuster.__version__ + " "
# "@@@@@@@@@@@@@@@@@@")
# blockbuster.bb_logging.logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
# blockbuster.bb_logging.logger.info("=== Application startup - " + str(datetime.datetime.now()) + " ====")
# blockbuster.bb_logging.logger.info(
# '================Time restriction disabled================') \
# if not blockbuster.config.timerestriction else blockbuster.bb_logging.logger.info(
# '================Time restriction enabled================')
#
# blockbuster.bb_logging.logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
#
# if blockbuster.config.debug_mode:
# blockbuster.bb_logging.logger.info("========= APPLICATION IS RUNNING IN DEBUG MODE ==========")
# This section only applies when you are running run.py directly
if __name__ == '__main__':
blockbuster.bb_logging.logger.info("Running http on port 5000")
blockbuster.app.run(host='0.0.0.0', debug=True) | __author__ = 'matt'
import datetime
import blockbuster
blockbuster.app.debug = blockbuster.config.debug_mode
blockbuster.bb_logging.logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
blockbuster.bb_logging.logger.info("@@@@@@@@@@@@@@@@@@ BlockBuster " + blockbuster.__version__ + " "
"@@@@@@@@@@@@@@@@@@")
blockbuster.bb_logging.logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
blockbuster.bb_logging.logger.info("=== Application startup - " + str(datetime.datetime.now()) + " ====")
blockbuster.bb_logging.logger.info(
'================Time restriction disabled================') \
if not blockbuster.config.timerestriction else blockbuster.bb_logging.logger.info(
'================Time restriction enabled================')
blockbuster.bb_logging.logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
if blockbuster.config.debug_mode:
blockbuster.bb_logging.logger.info("========= APPLICATION IS RUNNING IN DEBUG MODE ==========")
# This section only applies when you are running run.py directly
if __name__ == '__main__':
blockbuster.bb_logging.logger.info("Running http on port 5000")
blockbuster.app.run(host='0.0.0.0', debug=True) | mit | Python |
35028b84d4757e1343a97da653670db049ac5e8d | replace default handler with static handler | ihadzic/jim,ihadzic/jim,ihadzic/jim | web.py | web.py | #!/usr/bin/env python2
import tornado
import log
from tornado import web, httpserver
_http_server = None
_https_server = None
_html_root = './'
_log = None
# TODO: SSL needs this
# ssl_options['certfile'] - server certificate
# ssl_options['keyfile'] - server key
# ssl_options['ca_certs'] - CA certificate
def run_server(ssl_options = {}, http_port = 80, https_port = 443, log_facility = None, html_root = './'):
global _http_server
global _https_server
global _log
# list handlers for REST calls here
handlers = []
if log_facility:
_log = log_facility
else:
_log = log.TrivialLogger()
handlers.append(('/(.*)', web.StaticFileHandler, {'path': html_root}))
app = tornado.web.Application(handlers)
_log.info("creating servers")
_http_server = tornado.httpserver.HTTPServer(app, no_keep_alive = False)
_https_server = tornado.httpserver.HTTPServer(app, no_keep_alive = False, ssl_options = ssl_options)
_log.info("setting up TCP ports")
_http_server.listen(http_port)
_https_server.listen(https_port)
_log.info("starting server loop")
tornado.ioloop.IOLoop.instance().start()
_log.info("server loop exited")
| #!/usr/bin/env python2
import tornado
import log
import magic
from tornado import web, httpserver
_http_server = None
_https_server = None
_html_root = './'
_log = None
_magic = None
class DefaultHandler(tornado.web.RequestHandler):
def get(self, match):
_log.info("incoming request: {}".format(self.request))
_log.info("matched default match: {}".format(match))
self.set_header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0")
self.set_header("Connection", "close")
if match:
fname = _html_root + '/' + match
else:
fname = _html_root + '/index.html'
_log.info("fname: {}".format(fname))
try:
with open(fname, 'rb') as fd:
content = fd.read()
mime_type = _magic.file(fname)
self.set_header("Content-type", mime_type)
self.finish(content)
except:
self.set_status(404)
self.finish("Not found: {}".format(match))
_app = tornado.web.Application([
('/(.*)', DefaultHandler)
])
# TODO: SSL needs this
# ssl_options['certfile'] - server certificate
# ssl_options['keyfile'] - server key
# ssl_options['ca_certs'] - CA certificate
def run_server(ssl_options = {}, http_port = 80, https_port = 443, log_facility = None, html_root = './'):
global _http_server
global _https_server
global _log
global _magic
global _html_root
# http://www.zak.co.il/tddpirate/2013/03/03/the-python-module-for-file-type-identification-called-magic-is-not-standardized/
try:
_magic = magic.open(magic.MAGIC_MIME_TYPE)
_magic.load()
except AttributeError,e:
_magic = magic.Magic(mime=True)
_magic.file = _magic.from_file
if log_facility:
_log = log_facility
else:
_log = log.TrivialLogger()
_html_root = html_root
_log.info("creating servers")
_http_server = tornado.httpserver.HTTPServer(_app, no_keep_alive = False)
_https_server = tornado.httpserver.HTTPServer(_app, no_keep_alive = False, ssl_options = ssl_options)
_log.info("setting up TCP ports")
_http_server.listen(http_port)
_https_server.listen(https_port)
_log.info("starting server loop")
tornado.ioloop.IOLoop.instance().start()
_log.info("server loop exited")
| mit | Python |
d3f03d6e2cf48929f8233e52720b07242ccd64da | Put tweets back | samanehsan/spark_github,samanehsan/spark_github,samanehsan/learn-git,samanehsan/learn-git | web.py | web.py | """ Heroku/Python Quickstart: https://blog.heroku.com/archives/2011/9/28/python_and_django"""
import os
import random
import requests
from flask import Flask
import tweepy
import settings
app = Flask(__name__)
@app.route('/')
def home_page():
return 'Hello from the SPARK learn-a-thon!'
def get_instagram_image():
instagram_api_url = 'https://api.instagram.com/v1/tags/spark/media/recent?client_id={}'.format(settings.CLIENT_ID)
data = requests.get(instagram_api_url).json()['data']
number_of_images = choose_number_of_images()
images_returned = []
for image in number_of_images:
images_returned.append(random.choice(data)['images']['low_resolution']['url'])
return images_returned
def get_tweets():
auth = tweepy.OAuthHandler(settings.CONSUMER_KEY, settings.CONSUMER_SECRET)
auth.set_access_token(settings.ACCESS_KEY, settings.ACCESS_SECRET)
api = tweepy.API(auth)
number_of_tweets = choose_number_of_tweets()
tweets = tweepy.Cursor(api.search, q='#spark')
return tweets.items(limit=number_of_tweets)
def choose_number_of_images():
number = 3
return number
def choose_number_of_tweets():
number = 3
return number
if __name__ == '__main__':
# port = int(os.environ.get("PORT", 5000))
# app.run(host='0.0.0.0', port=port)
| """ Heroku/Python Quickstart: https://blog.heroku.com/archives/2011/9/28/python_and_django"""
import os
import random
import requests
from flask import Flask
import tweepy
import settings
app = Flask(__name__)
@app.route('/')
def home_page():
return 'Hello from the SPARK learn-a-thon!'
def get_instagram_image():
instagram_api_url = 'https://api.instagram.com/v1/tags/spark/media/recent?client_id={}'.format(settings.CLIENT_ID)
data = requests.get(instagram_api_url).json()['data']
number_of_images = choose_number_of_images()
images_returned = []
for image in number_of_images:
images_returned.append(random.choice(data)['images']['low_resolution']['url'])
return images_returned
def get_tweets():
auth = tweepy.OAuthHandler(settings.CONSUMER_KEY, settings.CONSUMER_SECRET)
auth.set_access_token(settings.ACCESS_KEY, settings.ACCESS_SECRET)
api = tweepy.API(auth)
number_of_tweets = choose_number_of_tweets()
return tweets.items(limit=number_of_tweets)
def choose_number_of_images():
number = 3
return number
def choose_number_of_tweets():
number = 3
return number
if __name__ == '__main__':
# port = int(os.environ.get("PORT", 5000))
# app.run(host='0.0.0.0', port=port)
| apache-2.0 | Python |
c772951ffbe06be23ff56d0281b78d7b9eac456b | Add option to generate executable name from the current branch | pycket/pycket,vishesh/pycket,magnusmorton/pycket,krono/pycket,pycket/pycket,cderici/pycket,magnusmorton/pycket,samth/pycket,samth/pycket,magnusmorton/pycket,cderici/pycket,vishesh/pycket,cderici/pycket,vishesh/pycket,samth/pycket,krono/pycket,pycket/pycket,krono/pycket | pycket/entry_point.py | pycket/entry_point.py | #! /usr/bin/env python
# -*- coding: utf-8 -*-
#
from pycket.expand import load_json_ast_rpython, expand_to_ast, PermException
from pycket.interpreter import interpret_one, ToplevelEnv, interpret_module, GlobalConfig
from pycket.error import SchemeException
from pycket.option_helper import parse_args, ensure_json_ast
from pycket.values import W_String
from rpython.rlib import jit
# _____ Define and setup target ___
def entry_point(argv):
try:
return actual_entry(argv)
except SchemeException, e:
print "ERROR:", e.msg
raise # to see interpreter-level traceback
def actual_entry(argv):
jit.set_param(None, "trace_limit", 20000)
config, names, args, retval = parse_args(argv)
if retval != 0 or config is None:
return retval
args_w = [W_String(arg) for arg in args]
module_name, json_ast = ensure_json_ast(config, names)
if json_ast is None:
ast = expand_to_ast(module_name)
else:
ast = load_json_ast_rpython(json_ast)
GlobalConfig.load(ast)
env = ToplevelEnv()
env.commandline_arguments = args_w
env.module_env.add_module(module_name, ast)
val = interpret_module(ast, env)
return 0
def target(driver, args):
if "--with-branch" in args:
import subprocess
base_name = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).strip()
else:
base_name = 'pycket-'
if driver.config.translation.jit:
driver.exe_name = base_name + '-%(backend)s'
else:
driver.exe_name = base_name + '-%(backend)s-nojit'
return entry_point, None
| #! /usr/bin/env python
# -*- coding: utf-8 -*-
#
from pycket.expand import load_json_ast_rpython, expand_to_ast, PermException
from pycket.interpreter import interpret_one, ToplevelEnv, interpret_module, GlobalConfig
from pycket.error import SchemeException
from pycket.option_helper import parse_args, ensure_json_ast
from pycket.values import W_String
from rpython.rlib import jit
# _____ Define and setup target ___
def entry_point(argv):
try:
return actual_entry(argv)
except SchemeException, e:
print "ERROR:", e.msg
raise # to see interpreter-level traceback
def actual_entry(argv):
jit.set_param(None, "trace_limit", 20000)
config, names, args, retval = parse_args(argv)
if retval != 0 or config is None:
return retval
args_w = [W_String(arg) for arg in args]
module_name, json_ast = ensure_json_ast(config, names)
if json_ast is None:
ast = expand_to_ast(module_name)
else:
ast = load_json_ast_rpython(json_ast)
GlobalConfig.load(ast)
env = ToplevelEnv()
env.commandline_arguments = args_w
env.module_env.add_module(module_name, ast)
val = interpret_module(ast, env)
return 0
def target(driver, args):
if driver.config.translation.jit:
driver.exe_name = 'pycket-%(backend)s'
else:
driver.exe_name = 'pycket-%(backend)s-nojit'
return entry_point, None
| mit | Python |
17fe4613518def551e637764e644c5d58b1665d9 | Add BodeAnalyser instrument to instrument table | liquidinstruments/pymoku | pymoku/instruments.py | pymoku/instruments.py | import sys
from . import _instrument
from . import _oscilloscope
from . import _waveform_generator
from . import _phasemeter
from . import _specan
from . import _lockinamp
from . import _datalogger
from . import _bodeanalyser
from . import _stream_instrument
from . import _frame_instrument
from . import _input_instrument
''' Preferred import point. Aggregates the separate instruments and helper classes
to flatten the import heirarchy (e.g. pymoku.instruments.Oscilloscope rather
than pymoku.instruments._oscilloscope.Oscilloscope)
'''
InstrumentData = _frame_instrument.InstrumentData
VoltsData = _oscilloscope.VoltsData
SpectrumData = _specan.SpectrumData
MokuInstrument = _instrument.MokuInstrument
Oscilloscope = _oscilloscope.Oscilloscope
WaveformGenerator = _waveform_generator.WaveformGenerator
Phasemeter = _phasemeter.Phasemeter
SpectrumAnalyser = _specan.SpectrumAnalyser
LockInAmp = _lockinamp.LockInAmp
Datalogger = _datalogger.Datalogger
BodeAnalyser = _bodeanalyser.BodeAnalyser
id_table = {
1: Oscilloscope,
2: SpectrumAnalyser,
3: Phasemeter,
4: WaveformGenerator,
5: None,
6: None,
7: Datalogger,
8: LockInAmp,
9: BodeAnalyser,
10: None,
11: None,
12: None,
13: None,
14: None
}
| import sys
from . import _instrument
from . import _oscilloscope
from . import _waveform_generator
from . import _phasemeter
from . import _specan
from . import _lockinamp
from . import _datalogger
from . import _bodeanalyser
from . import _stream_instrument
from . import _frame_instrument
from . import _input_instrument
''' Preferred import point. Aggregates the separate instruments and helper classes
to flatten the import heirarchy (e.g. pymoku.instruments.Oscilloscope rather
than pymoku.instruments._oscilloscope.Oscilloscope)
'''
InstrumentData = _frame_instrument.InstrumentData
VoltsData = _oscilloscope.VoltsData
SpectrumData = _specan.SpectrumData
MokuInstrument = _instrument.MokuInstrument
Oscilloscope = _oscilloscope.Oscilloscope
WaveformGenerator = _waveform_generator.WaveformGenerator
Phasemeter = _phasemeter.Phasemeter
SpectrumAnalyser = _specan.SpectrumAnalyser
LockInAmp = _lockinamp.LockInAmp
Datalogger = _datalogger.Datalogger
BodeAnalyser = _bodeanalyser.BodeAnalyser
id_table = {
1: Oscilloscope,
2: SpectrumAnalyser,
3: Phasemeter,
4: WaveformGenerator,
5: None,
6: None,
7: Datalogger,
8: LockInAmp,
9: None,
10: None,
11: None,
12: None,
13: None,
14: None
}
| mit | Python |
c034282423d47a6530ed0bb77c54e133de72115b | add more verbose output to PushwooshClient when debut=True | Pushwoosh/pushwoosh-python-lib | pypushwoosh/client.py | pypushwoosh/client.py | import logging
import requests
from .base import PushwooshBaseClient
log = logging.getLogger('pypushwoosh.client.log')
class PushwooshClient(PushwooshBaseClient):
"""
Implementation of the Pushwoosh API Client.
"""
headers = {'User-Agent': 'PyPushwooshClient',
'Content-Type': 'application/json',
'Accept': 'application/json'}
def __init__(self, timeout=None):
PushwooshBaseClient.__init__(self)
self.timeout = timeout
def path(self, command):
return '{}://{}/'.format(self.scheme, self.hostname) + '/'.join((self.endpoint, self.version,
command.command_name))
def invoke(self, command):
PushwooshBaseClient.invoke(self, command)
url = self.path(command)
payload = command.render()
if self.debug:
log.debug('Client: %s' % self.__class__.__name__)
log.debug('Command: %s' % payload)
log.debug('Request URL: %s' % url)
log.debug('Request method: %s' % self.method)
log.debug('Request headers: %s' % self.headers)
r = requests.post(url, data=payload, headers=self.headers, timeout=self.timeout)
if self.debug:
log.debug('Response version: %s' % r.raw.version)
log.debug('Response code: %s' % r.status_code)
log.debug('Response phrase: %s' % r.reason)
log.debug('Response headers: %s' % r.headers)
log.debug('Response payload: %s' % r.json())
return r.json()
| import logging
import requests
from .base import PushwooshBaseClient
log = logging.getLogger('pypushwoosh.client.log')
class PushwooshClient(PushwooshBaseClient):
"""
Implementation of the Pushwoosh API Client.
"""
headers = {'User-Agent': 'PyPushwooshClient',
'Content-Type': 'application/json',
'Accept': 'application/json'}
def __init__(self, timeout=None):
PushwooshBaseClient.__init__(self)
self.timeout = timeout
def path(self, command):
return '{}://{}/'.format(self.scheme, self.hostname) + '/'.join((self.endpoint, self.version,
command.command_name))
def invoke(self, command):
PushwooshBaseClient.invoke(self, command)
if self.debug:
log.debug('Client: %s' % self.__class__.__name__)
log.debug('Command: %s' % command.render())
log.debug('Request URL: %s://%s%s' % (self.scheme, self.hostname, self.path(command)))
log.debug('Request method: %s' % self.method)
log.debug('Request headers: %s' % self.headers)
r = requests.post(self.path(command), data=command.render(), headers=self.headers, timeout=self.timeout)
if self.debug:
log.debug('Response version: %s' % r.raw.version)
log.debug('Response code: %s' % r.status_code)
log.debug('Response phrase: %s' % r.reason)
log.debug('Response headers: %s' % r.headers)
return r.json()
| mit | Python |
17474a74a8c382c1cc5923c0e2128e4a4e776553 | Add method I am yet to use | israelg99/eva | eva/util/nutil.py | eva/util/nutil.py | import numpy as np
def to_rgb(pixels):
return np.repeat(pixels, 3 if pixels.shape[2] == 1 else 1, 2)
def binarize(arr, generate=np.random.uniform):
return (generate(size=arr.shape) < arr).astype('i')
def quantisize(arr, levels):
return (np.digitize(arr, np.arange(levels) / levels) - 1).astype('i')
| import numpy as np
def to_rgb(pixels):
return np.repeat(pixels, 3 if pixels.shape[2] == 1 else 1, 2)
def binarize(arr, generate=np.random.uniform):
return (generate(size=arr.shape) < arr).astype('i')
| apache-2.0 | Python |
fb2cfe4759fb98de644932af17a247428b2cc0f5 | Fix Auth API key check causing error 500s | nikdoof/test-auth | api/auth.py | api/auth.py | from django.http import HttpResponseForbidden
from django.contrib.auth.models import AnonymousUser
from api.models import AuthAPIKey
class APIKeyAuthentication(object):
def is_authenticated(self, request):
params = {}
for key,value in request.GET.items():
params[key.lower()] = value
if 'apikey' in params:
try:
keyobj = AuthAPIKey.objects.get(key=params['apikey'])
except:
keyobj = None
if keyobj and keyobj.active:
request.user = AnonymousUser()
return True
return False
def challenge(self):
return HttpResponseForbidden('Access Denied, use a API Key')
| from django.http import HttpResponseForbidden
from django.contrib.auth.models import AnonymousUser
from api.models import AuthAPIKey
class APIKeyAuthentication(object):
def is_authenticated(self, request):
params = {}
for key,value in request.GET.items():
params[key.lower()] = value
if params['apikey']:
try:
keyobj = AuthAPIKey.objects.get(key=params['apikey'])
except:
keyobj = None
if keyobj and keyobj.active:
request.user = AnonymousUser()
return True
return False
def challenge(self):
return HttpResponseForbidden('Access Denied, use a API Key')
| bsd-3-clause | Python |