prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
thrift_import_target = self.get_options().thrift_import_target thrift_imports = self.context.resolve(thrift_import_target) return thrift_imports
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
service_deps = self.get_options().get('service_deps') return list(self.resolve_deps(service_deps)) if service_deps else self._deps
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
with open(source) as thrift: return any(line for line in thrift if self.SERVICE_PARSER.search(line))
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
with open(source) as thrift: namespace = self.NAMESPACE_PARSER.search(thrift.read()) if not namespace: raise TaskError('Thrift file {} must contain "namespace go "', source) return namespace.group(1)
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
for source in target.sources_relative_to_buildroot(): if self._declares_service(os.path.join(get_buildroot(), source)): return self._service_deps return self._deps
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
return GoThriftGenLibrary
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
return isinstance(target, GoThriftLibrary)
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
cmd = [self._thrift_binary] thrift_import = 'thrift_import={}'.format(self.get_options().thrift_import) gen_options = self.get_options().gen_options if gen_options: gen_options += ',' + thrift_import else: gen_options = thrift_import cmd.extend(('--gen', 'go:{}'.format(gen_options)))...
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
target_cmd = self._thrift_cmd[:] bases = OrderedSet(tgt.target_base for tgt in target.closure() if self.is_gentarget(tgt)) for base in bases: target_cmd.extend(('-I', base)) target_cmd.extend(('-o', target_workdir)) all_sources = list(target.sources_relative_to_buildroot()) if len(all_s...
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
return ['go']
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
self._generate_thrift(target, target_workdir)
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
"""Override `_copy_target_attributes` to exclude `provides`.""" return [a for a in super(GoThriftGen, self)._copy_target_attributes if a != 'provides']
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
all_sources = list(target.sources_relative_to_buildroot()) source = all_sources[0] namespace = self._get_go_namespace(source) return os.path.join(target_workdir, 'src', 'go', namespace.replace(".", os.path.sep))
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
raise TaskError('Thrift file {} must contain "namespace go "', source)
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
return self._service_deps
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
gen_options += ',' + thrift_import
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
gen_options = thrift_import
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
cmd.append('-strict')
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
cmd.append('-verbose')
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
raise TaskError('go_thrift_library only supports a single .thrift source file for {}.', target)
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
raise TaskError('{} ... exited non-zero ({})'.format(self._thrift_binary, result))
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
register_options
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
subsystem_dependencies
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
_thrift_binary
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
_deps
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
_service_deps
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
_declares_service
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
_get_go_namespace
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
synthetic_target_extra_dependencies
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
synthetic_target_type
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
is_gentarget
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
_thrift_cmd
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
_generate_thrift
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
product_types
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
execute_codegen
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
_copy_target_attributes
<|file_name|>go_thrift_gen.py<|end_file_name|><|fim▁begin|># coding=utf-8 # Copyright 2014 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, ...
synthetic_target_dir
<|file_name|>test_blog_settings.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (c) 2020, Frappe Technologies and Contributors<|fim▁hole|># See license.txt from __future__ import unicode_literals # import frappe import unittest class TestBlogSettings(unittest.TestCase): pass<|fim▁end|>
<|file_name|>test_blog_settings.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # Copyright (c) 2020, Frappe Technologies and Contributors # See license.txt from __future__ import unicode_literals # import frappe import unittest class TestBlogSettings(unittest.TestCase): <|fim_middle|> <|fim▁end|>
pass
<|file_name|>cache.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from cachy import CacheManager from cachy.serializers import PickleSerializer class Cache(CacheManager): _serializers = { 'pickle': PickleSerializer()<|fim▁hole|><|fim▁end|>
}
<|file_name|>cache.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from cachy import CacheManager from cachy.serializers import PickleSerializer class Cache(CacheManager): <|fim_middle|> <|fim▁end|>
_serializers = { 'pickle': PickleSerializer() }
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): data = urllib2.u...
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): <|fim_middle|> def get_drinker_list(): data = urllib2.urlopen("http://192.168.11.5:8080/drinkcounter/get_datas/").read().split("\n") drinkers = [] for data_row in d...
def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): <|fim_middle|> def get_drinker_list(): data = urllib2.urlopen("http://192.168.11.5:8080/drinkcounter/get_datas/").read().split("\n") drinkers...
self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): <|fim_middle|> ...
data = urllib2.urlopen("http://192.168.11.5:8080/drinkcounter/get_datas/").read().split("\n") drinkers = [] for data_row in data: if data_row == '': continue fields = data_row.split('|') drinker = Drinker() drinker.id = int(fields[0]) drinker.name = fields[1] ...
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): data = urllib2.u...
items = [] for drinker in drinkers: items.append(unicode('%s, %d drinks, %s' % (drinker.name, drinker.drinks, drinker.idle))) return items
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): data = urllib2.u...
app_lock.signal()
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): data = urllib2.u...
selected_drinker = drinkers[lb.current()] urllib2.urlopen("http://192.168.11.5:8080/drinkcounter/add_drink/%d/" % (selected_drinker.id)) appuifw.note(u"A drink has been added to " + drinkers[lb.current()].name, 'info') new_drinkers = get_drinker_list() items = get_listbox_items(new_drinkers) l...
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): data = urllib2.u...
continue
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def <|fim_middle|>(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): data = url...
__init__
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def <|fim_middle|>(): data = urllib2.url...
get_drinker_list
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): data = urllib2.u...
get_listbox_items
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): data = urllib2.u...
quit
<|file_name|>client.py<|end_file_name|><|fim▁begin|>import urllib2 import appuifw, e32 from key_codes import * class Drinker(object): def __init__(self): self.id = 0 self.name = "" self.prom = 0.0 self.idle = "" self.drinks = 0 def get_drinker_list(): data = urllib2.u...
handle_selection
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>''' salt.utils ~~~~~~~~~~ ''' <|fim▁hole|>class lazy_property(object): ''' meant to be used for lazy evaluation of an object attribute. property should represent non-mutable data, as it replaces itself. http://stackoverflow.com/a/6849299/564003 ...
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>''' salt.utils ~~~~~~~~~~ ''' class lazy_property(object): <|fim_middle|> <|fim▁end|>
''' meant to be used for lazy evaluation of an object attribute. property should represent non-mutable data, as it replaces itself. http://stackoverflow.com/a/6849299/564003 ''' def __init__(self, fget): self.fget = fget self.func_name = fget.__name__ def __get__(self, obj...
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>''' salt.utils ~~~~~~~~~~ ''' class lazy_property(object): ''' meant to be used for lazy evaluation of an object attribute. property should represent non-mutable data, as it replaces itself. http://stackoverflow.com/a/6849299/564003 ''' ...
self.fget = fget self.func_name = fget.__name__
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>''' salt.utils ~~~~~~~~~~ ''' class lazy_property(object): ''' meant to be used for lazy evaluation of an object attribute. property should represent non-mutable data, as it replaces itself. http://stackoverflow.com/a/6849299/564003 ''' ...
if obj is None: return None value = self.fget(obj) setattr(obj, self.func_name, value) return value
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>''' salt.utils ~~~~~~~~~~ ''' class lazy_property(object): ''' meant to be used for lazy evaluation of an object attribute. property should represent non-mutable data, as it replaces itself. http://stackoverflow.com/a/6849299/564003 ''' ...
return None
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>''' salt.utils ~~~~~~~~~~ ''' class lazy_property(object): ''' meant to be used for lazy evaluation of an object attribute. property should represent non-mutable data, as it replaces itself. http://stackoverflow.com/a/6849299/564003 ''' ...
__init__
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>''' salt.utils ~~~~~~~~~~ ''' class lazy_property(object): ''' meant to be used for lazy evaluation of an object attribute. property should represent non-mutable data, as it replaces itself. http://stackoverflow.com/a/6849299/564003 ''' ...
__get__
<|file_name|>solution.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 import re a = [[0 for x in range(25)] for y in range(13)] f=open("../distrib/spiral.txt","r") s=f.readline().strip() dx, dy = [0, 1, 0, -1], [1, 0, -1, 0] x, y, c = 0, -1, 1 l=0 for i in range(13+13-1): if i%2==0: for j in range((2...
x += dx[i % 4]
<|file_name|>solution.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 import re a = [[0 for x in range(25)] for y in range(13)] f=open("../distrib/spiral.txt","r") s=f.readline().strip() dx, dy = [0, 1, 0, -1], [1, 0, -1, 0] x, y, c = 0, -1, 1 l=0 for i in range(13+13-1): if i%2==0: <|fim_mid...
for j in range((25+25-i)//2): x += dx[i % 4] y += dy[i % 4] #print(x,y,l) a[x][y] = s[l] l=l+1 c += 1
<|file_name|>solution.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 import re a = [[0 for x in range(25)] for y in range(13)] f=open("../distrib/spiral.txt","r") s=f.readline().strip() dx, dy = [0, 1, 0, -1], [1, 0, -1, 0] x, y, c = 0, -1, 1 l=0 for i in range(13+13-1): if i%2==0: for j in range((2...
for j in range((13+13-i)//2): x += dx[i % 4] y += dy[i % 4] #print(x,y,l) a[x][y] = s[l] l=l+1 c += 1
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>__author__ = 'mwn' import os import sys import logging from logging.handlers import RotatingFileHandler from flask import Flask, render_template app = Flask(__name__) app.config.from_object('config') handler = RotatingFileHandler('yapki.log', maxBytes=10000, back...
to create it from a shell with a random key, then exit. """ filename = os.path.join(app.instance_path, filename)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>__author__ = 'mwn' import os import sys import logging from logging.handlers import RotatingFileHandler from flask import Flask, render_template app = Flask(__name__) app.config.from_object('config') handler = RotatingFileHandler('yapki.log', maxBytes=10000, back...
"""Configure the SECRET_KEY from a file in the instance directory. If the file does not exist, print instructions to create it from a shell with a random key, then exit. """ filename = os.path.join(app.instance_path, filename) try: app.config['SECRET_KEY'] = open(filename, 'rb'...
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>__author__ = 'mwn' import os import sys import logging from logging.handlers import RotatingFileHandler from flask import Flask, render_template app = Flask(__name__) app.config.from_object('config') handler = RotatingFileHandler('yapki.log', maxBytes=10000, back...
return render_template('404.html'), 404
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>__author__ = 'mwn' import os import sys import logging from logging.handlers import RotatingFileHandler from flask import Flask, render_template app = Flask(__name__) app.config.from_object('config') handler = RotatingFileHandler('yapki.log', maxBytes=10000, back...
response.headers.add('X-Test', 'This is only test.') response.headers.add('Access-Control-Allow-Origin', '*') # TODO: set to real origin return response
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>__author__ = 'mwn' import os import sys import logging from logging.handlers import RotatingFileHandler from flask import Flask, render_template app = Flask(__name__) app.config.from_object('config') handler = RotatingFileHandler('yapki.log', maxBytes=10000, back...
print('mkdir -p {filename}'.format(filename=full_path))
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>__author__ = 'mwn' import os import sys import logging from logging.handlers import RotatingFileHandler from flask import Flask, render_template app = Flask(__name__) app.config.from_object('config') handler = RotatingFileHandler('yapki.log', maxBytes=10000, back...
install_secret_key(app)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>__author__ = 'mwn' import os import sys import logging from logging.handlers import RotatingFileHandler from flask import Flask, render_template app = Flask(__name__) app.config.from_object('config') handler = RotatingFileHandler('yapki.log', maxBytes=10000, back...
install_secret_key
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>__author__ = 'mwn' import os import sys import logging from logging.handlers import RotatingFileHandler from flask import Flask, render_template app = Flask(__name__) app.config.from_object('config') handler = RotatingFileHandler('yapki.log', maxBytes=10000, back...
not_found
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|>__author__ = 'mwn' import os import sys import logging from logging.handlers import RotatingFileHandler from flask import Flask, render_template app = Flask(__name__) app.config.from_object('config') handler = RotatingFileHandler('yapki.log', maxBytes=10000, back...
after_request
<|file_name|>vectores.py<|end_file_name|><|fim▁begin|>from vectores_oo import Vector x = input('vector U componente X= ') y = input('vector U componente X= ') U = Vector(x,y) m = input('vector V magnitud= ') a = input('vector V angulo= ') V = Vector(m=m, a=a) E = input('Escalar= ') print "U=%s" % U<|fim▁hole|...
print "V=%s" % V
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
response = cli_command("gpio dio") if "D1: DOUT=OFF, DIN=LOW" in response:
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
""" Return a timestamp, in milliseconds :return ms_timestamp: int, Timestamp in milliseconds """ ms_timestamp = int(time.time() * 1000) return ms_timestamp
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
""" Send a command to the SarOS CLI and receive the response :param cmd: str, Command to run :return response: str, Response to cmd """ cli = sarcli.open() cli.write(cmd) response = cli.read() cli.close() return response
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
""" Send an SMS alert """ def __init__(self, destination, custom_text): self.destination = destination self.custom_text = custom_text def send_alert(self, message): """ Send an SMS alert :param message: str, Content of SMS message :return r...
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
self.destination = destination self.custom_text = custom_text
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
""" Send an SMS alert :param message: str, Content of SMS message :return response: str, Response to sendsms command """ message = "{0}: {1}".format(self.custom_text, message) command = 'sendsms ' + self.destination + ' "' + message + '" ' response ...
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
""" Send a Datapoint alert """ def __init__(self, destination): self.destination = destination def send_alert(self, message): """ Send a Datapoint alert :param message: str, Datapoint content :return response: tuple, Result code of datapoint upload ...
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
self.destination = destination
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
""" Send a Datapoint alert :param message: str, Datapoint content :return response: tuple, Result code of datapoint upload attempt """ timestamp = millisecond_timestamp() dpoint = """\ <DataPoint> <dataType>STRING</dataType> ...
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
""" Provides methods to monitor the enclosure door status """ def __init__(self, alert_list): self.d1_status = "" self.alert_list = alert_list @classmethod def switch_status(cls): """ Reads line status and sends an alert if the status is different ...
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
self.d1_status = "" self.alert_list = alert_list
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
""" Reads line status and sends an alert if the status is different :return status: str, Door status, "OPEN" or "CLOSED" """ response = cli_command("gpio dio") if "D1: DOUT=OFF, DIN=LOW" in response: if not "D0: DOUT=ON" in response: # D...
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
""" :param text: str, Alert content :return: """ for alert in self.alert_list: alert.send_alert(text)
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
""" Runs line monitoring and alerting in a loop :return: """ while True: status = self.switch_status() if status != self.d1_status: print "WR31 door is: {0}".format(status) self.send_alert(status) se...
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
if not "D0: DOUT=ON" in response: # Door is closed status = "CLOSED"
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
status = "CLOSED"
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
status = "OPEN"
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
print "WR31 door is: {0}".format(status) self.send_alert(status) self.d1_status = status
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
ALERT_FUNCTIONS = [DatapointAlert("WR31_door")] if len(sys.argv) >= 3: CUSTOM_TEXT = sys.argv[2] else: CUSTOM_TEXT = "WR31 Door" if len(sys.argv) >= 2: ALERT_FUNCTIONS.append(SmsAlert(sys.argv[1], CUSTOM_TEXT)) MONITOR = DoorMonitor(ALERT_FUNCTIONS) MONITOR.monito...
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
CUSTOM_TEXT = sys.argv[2]
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
CUSTOM_TEXT = "WR31 Door"
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
ALERT_FUNCTIONS.append(SmsAlert(sys.argv[1], CUSTOM_TEXT))
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
millisecond_timestamp
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
cli_command
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
__init__
<|file_name|>doormon.py<|end_file_name|><|fim▁begin|># This Source Code Form is subject to the terms of the Mozilla Public # License, v. 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/. # # Copyright (c) 2016 Digi International Inc. All Rights Reserv...
send_alert