repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
ofirshi/SmartMove
bin/Debug/SmartConnector/smartconnector.py
#!/usr/bin/env python import sys import argparse import json import os sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '.'))) from cpapi import APIClient, APIClientArgs # printing messages to console and log file # res_action - response from server, used if response is not OK # message - mes...
uriegel/registry-changes-detector
binding.gyp
<gh_stars>1-10 { "targets": [{ "target_name": "registry-changes-detector", "sources": [ 'addon.cpp' ], 'include_dirs': [ "<!@(node -p \"require('node-addon-api').include\")", "<!@(node -p \"var a = require('node-addon-api').include; var b = a.subs...
QuiNovas/tfe-dependency-manager
src/lambda_function/function.py
import boto3 import hmac import json import logging.config import re import requests from boto3.dynamodb.conditions import Attr from hashlib import sha512 from os import environ BASE_TFE_API_URL = 'https://app.terraform.io/api/v2' CURRENT_STATE_VERSION_API_URL = BASE_TFE_API_URL + '/workspaces/{}/current-state-versio...
makaramkd/thenewboston-python-client
tnb/validators.py
from tnb.base_client import BaseClient class Validator(BaseClient): def fetch_accounts(self, offset: int = 0, limit: int = 50) -> dict: """ Fetch accounts from validator :param offset: The offset to start at. Default: 0 :param limit: The limit of results to retrieve. Default: 50 ...
leferrad/tensorflow-mobilenet
scripts/make_inferences.py
from __future__ import print_function from mobilenet.core import MobileNetV1Restored from mobilenet.fileio import get_logger from mobilenet.imagenet import LabelLookup import os import argparse logger = get_logger(name="make_inferences", level='debug') if __name__ == '__main__': parser = argparse.ArgumentPars...
leferrad/tensorflow-mobilenet
scripts/convert_tflite_model.py
from __future__ import print_function """Script to convert a model in Protobuf format into a one in TFLite format""" from mobilenet.core import MobileNetV1Restored from mobilenet.fileio import get_logger import os import argparse logger = get_logger(name="make_inferences", level='debug') if __name__ == '__main__...
leferrad/tensorflow-mobilenet
mobilenet/toco.py
<filename>mobilenet/toco.py # Copyright 2017 The TensorFlow Authors. 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 # ...
leferrad/tensorflow-mobilenet
mobilenet/imagenet.py
# Copyright 2016 The TensorFlow Authors. 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 ...
leferrad/tensorflow-mobilenet
mobilenet/paths.py
<gh_stars>1-10 #!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import os CWD = os.path.abspath(__file__) def get_mobilenet_path(): return os.path.abspath(os.path.join(CWD, os.path.pardir)) def get_root_path(): return os.path.abspath(os.path.join(get_mobilenet_path(), o...
leferrad/tensorflow-mobilenet
mobilenet/fileio.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import logging import logging.handlers import tarfile import os import json from sys import stdout from six.moves import urllib def get_logger(name='mobilenet', level='debug'): """ Function to obtain a normal logger :pa...
leferrad/tensorflow-mobilenet
mobilenet/core.py
<gh_stars>1-10 # Copyright 2017 The TensorFlow Authors. 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...
leferrad/tensorflow-mobilenet
scripts/freeze_graph.py
from __future__ import print_function from mobilenet.core import MobileNetDefaultFile, MobileNetV1Restored from mobilenet.fileio import download_and_uncompress_tarball, get_logger from mobilenet.imagenet import create_readable_names_for_imagenet_labels import os import re import json import argparse logger = get_lo...
mdshaffer8/TeachersAid
config.py
<filename>config.py import os from os.path import join, isfile from werkzeug.utils import secure_filename basedir = os.path.abspath(os.path.dirname(__file__)) class Config(object): SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess' SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \...
mdshaffer8/TeachersAid
migrations/versions/89f0e7905ca9_uploads.py
<filename>migrations/versions/89f0e7905ca9_uploads.py<gh_stars>0 """uploads Revision ID: 89f0e7905ca9 Revises: <PASSWORD> Create Date: 2018-06-07 10:42:40.640721 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = '89f0e7905ca9' down_revision = '<PASSWORD>' branch_...
mdshaffer8/TeachersAid
teachersaid/__init__.py
from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_bcrypt import Bcrypt from flask_login import LoginManager from flask_mail import Mail from flask_uploads import UploadSet, IMAGES, configure_uploads from flask_migrate import Migrate from config import Config app = Flask(__name__) app.confi...
mdshaffer8/TeachersAid
old/bluprint/main/routes.py
from flask import render_template, request, Blueprint from teachersaid.models import Post main = Blueprint('main', __name__) @main.route("/") @main.route("/home") def home(): return render_template('home.html', title='Home') @main.route("/list") def list(): page = request.args.get('page', 1, type=int) ...
fionahiklas/udp-broadcast-examples
udp-client.py
<filename>udp-client.py<gh_stars>0 import socket, traceback host = '255.255.255.255' # Bind to all interfaces port = 2081 print "Creating socker on port: ", port s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #print "Setting REUSEADDR option" #s.setsockopt(socket.SOL_SOCKET, socke...
fionahiklas/udp-broadcast-examples
udp-server.py
import socket, traceback host = '0.0.0.0' # Bind to all interfaces port = 2081 print "Creating socker on port: ", port s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #print "Setting REUSEADDR option" #s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) print "Setting SO_BROAD...
aaronbenz/flask-restplus
benchmarks/swagger.bench.py
from minibench import Benchmark from faker import Faker from flask import Flask from flask_restplus import fields, Api, Resource from flask_restplus.swagger import Swagger fake = Faker() api = Api() person = api.model('Person', { 'name': fields.String, 'age': fields.Integer }) family = api.model('Family', ...
aaronbenz/flask-restplus
tests/test_payload.py
<filename>tests/test_payload.py # -*- coding: utf-8 -*- from __future__ import unicode_literals import json import flask_restplus as restplus from . import TestCase class PayloadTestCase(TestCase): def post(self, url, data): with self.app.test_client() as client: return client.post(url, dat...
aaronbenz/flask-restplus
setup.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # flake8: noqa from __future__ import unicode_literals import re import sys from setuptools import setup, find_packages RE_REQUIREMENT = re.compile(r'^\s*-r\s*(?P<filename>.*)$') PYPI_RST_FILTERS = ( # Replace code-blocks (r'\.\.\s? code-block::\s*(\w|\+)+', '::...
aaronbenz/flask-restplus
tasks.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals, absolute_import from invoke import run, task from os.path import join, abspath, dirname ROOT = abspath(join(dirname(__file__))) def lrun(cmd, *args, **kwargs): '''Run a command ensuring cwd is project root''' return run('cd {0} && {1}'.format...
aaronbenz/flask-restplus
benchmarks/marshal.bench.py
from minibench import Benchmark from faker import Faker from flask import Flask from flask_restplus import marshal, fields fake = Faker() person_fields = { 'name': fields.String, 'age': fields.Integer } family_fields = { 'father': fields.Nested(person_fields), 'mother': fields.Nested(person_fields)...
mpg-age-bioinformatics/b
bit/rsync.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import sys import getpass from os.path import expanduser from subprocess import Popen, PIPE, STDOUT import stat import tempfile import bit.config as config def get_remote_config(sshLogin,remotePass):...
mpg-age-bioinformatics/b
bit/automation.py
<reponame>mpg-age-bioinformatics/b import smtplib from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email.mime.text import MIMEText from email import encoders import re import subprocess from subprocess import Popen, PIPE, STDOUT import requests import json import sys import o...
mpg-age-bioinformatics/b
bit/__init__.py
<gh_stars>1-10 #!/usr/bin/env python from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import sys from subprocess import Popen, PIPE, STDOUT import stat import shlex import bit.config as config import bit.git as git import bit.owncloud as oc import b...
mpg-age-bioinformatics/b
bit/owncloud.py
<reponame>mpg-age-bioinformatics/b<gh_stars>1-10 from __future__ import absolute_import from __future__ import division from __future__ import print_function import time import datetime import os import sys import getpass import bit.config as config import bit.git as git import bit._owncloud as owncloud def list_uplo...
mpg-age-bioinformatics/b
setup.py
from setuptools import setup setup(name = 'bit', version = '0.2.0', description = '[b]ermuda [i]nformation [t]riangle', url = 'https://github.com/mpg-age-bioinformatics/bit', author = 'Bioinformatics Core Facility of the Max Planck Institute for Biology of Ageing', author_email = '<EMAIL>...
mpg-age-bioinformatics/b
bit/config.py
<gh_stars>1-10 from __future__ import absolute_import from __future__ import division from __future__ import print_function import json import os import sys import getpass from os.path import expanduser import stat import shutil import bit.git as git structure="\n\ /file_system_a\n\ |\n\ '- data\n\ |\...
mpg-age-bioinformatics/b
bit/git.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import sys import subprocess as sb from subprocess import Popen, PIPE, STDOUT import requests import json def git_target(github_address,github_organization,github_repo,github_user=None,github_pass=Non...
abs51295/fabric8-analytics-rudra
rudra/data_store/bigquery/base.py
<filename>rudra/data_store/bigquery/base.py """Implementation Bigquery builder base.""" import os import time import tempfile import json from google.cloud import bigquery from rudra import logger from rudra.data_store.aws import AmazonS3 _POLLING_DELAY = 1 # sec class BigqueryBuilder: """BigqueryBuilder clas...
abs51295/fabric8-analytics-rudra
tests/data_store/bigquery/test_maven_bigquery.py
import types import tempfile import shutil import json import pathlib import pytest import mock from tests.data_store.bigquery.test_base import MockBigQuery from rudra.data_store.local_data_store import LocalDataStore class MockS3(LocalDataStore): def __init__(self, *args, **kwargs): super().__init__(...
abs51295/fabric8-analytics-rudra
rudra/deployments/emr_scripts/__init__.py
<filename>rudra/deployments/emr_scripts/__init__.py """EMR Deployments.""" from rudra.deployments.emr_scripts.maven_emr import MavenEMR from rudra.deployments.emr_scripts.npm_emr import NpmEMR from rudra.deployments.emr_scripts.pypi_emr import PyPiEMR __all__ = ['MavenEMR', 'NpmEMR', 'PyPiEMR']
abs51295/fabric8-analytics-rudra
rudra/deployments/emr_scripts/emr_config.py
"""Configurations for EMR instance.""" class EMRConfig: """Config class for EMR.""" home_dir = '/home/hadoop' def __init__(self, name, log_uri, ecosystem, s3_bootstrap_uri, training_repo_url, training_file_name='training/train.py', release_label='emr-5.10.0', instance_c...
abs51295/fabric8-analytics-rudra
tests/utils/test_validation.py
from rudra.utils.validation import check_field_exists, check_url_alive, BQValidation import pytest def test_check_field_exists(): input_data = ['a', 'b', 'c'] missing = check_field_exists(input_data, ['a', 'd']) assert 'd' in missing missing = check_field_exists(input_data, ['a', 'c']) assert not ...
abs51295/fabric8-analytics-rudra
tests/data_store/bigquery/test_pypi_bigquery.py
import types import tempfile import shutil import json import pathlib import pytest import mock from tests.data_store.bigquery.test_base import MockBigQuery from rudra.data_store.local_data_store import LocalDataStore class MockS3(LocalDataStore): def __init__(self, *args, **kwargs): super().__init__(...
ant1fact/jalapino-api
tests/conftest.py
import pytest from api import create_app from api.config import TestConfig def make_auth_header(role: str) -> str: assert role in {'customer', 'restaurant'} tokens = { 'customer': TestConfig.CUSTOMER_TOKEN, 'restaurant': TestConfig.RESTAURANT_TOKEN } return {'Authorization': f'Bearer {t...
ant1fact/jalapino-api
tests/test_api_rbac.py
from api.models import Category, Customer, Item, Restaurant from conftest import create_app, make_auth_header app = create_app() ### RESTAURANTS ### def test_pass_get_restaurants(client): response = client.get('/restaurants') assert response.status_code == 200 restaurants = response.get_json() asse...
ant1fact/jalapino-api
api/config.py
<reponame>ant1fact/jalapino-api<filename>api/config.py from os import getenv # Config inspired by: # https://github.com/miguelgrinberg/flasky/blob/master/config.py class Config: SECRET_KEY = getenv('CLIENT_SECRET') SQLALCHEMY_DATABASE_URI = getenv( 'SQLALCHEMY_DATABASE_URI', # If SQLALCHEMY_D...
ant1fact/jalapino-api
api/__init__.py
from flask import Flask, redirect from flask_cors import CORS from flask_migrate import Migrate from . import config def create_app(config=config.Config): app = Flask(__name__) app.config.from_object(config) from .models import db db.init_app(app) Migrate(app, db) CORS(app) from .api i...
ant1fact/jalapino-api
api/api.py
<reponame>ant1fact/jalapino-api import json from flask import ( Blueprint, Response, abort, jsonify, redirect, render_template, request, ) from werkzeug.exceptions import HTTPException from .auth import AuthError, requires_auth api = Blueprint('api', __name__) from .config import Config...
ant1fact/jalapino-api
api/models.py
from flask_sqlalchemy import Model, SQLAlchemy from sqlalchemy import inspect DEFAULT_LOGO_URI = 'https://raw.githubusercontent.com/ant1fact/jalapino/fullstack/static/images/jalapino_150x150.png' PROTECTED_COLUMN_NAMES = {'id', 'auth0_id'} class CRUDModel(Model): '''Extended model with C(R)UD methods.''' de...
0000Blaze/Smart-Attendance
server/initiallInsertsForDb.py
import csv import insertdb import cv2 import numpy as np ####################################department insertion########################## departmentDb = { "1": "Department of Architecture", "2": "Department of Civil Engineering", "3": "Department of Electrical Engineering", "4": "Department of Mechan...
0000Blaze/Smart-Attendance
teacherApp/teacher.py
from server import client_teacher from numpy import spacing from kivymd.app import MDApp from kivymd.uix.boxlayout import MDBoxLayout from kivymd.uix.button import MDRaisedButton from kivymd.uix.label import MDLabel from kivy.uix.image import Image from kivymd.uix.textfield import MDTextField from kivymd.uix.datatabl...
0000Blaze/Smart-Attendance
teacherApp/server/communication_json.py
<reponame>0000Blaze/Smart-Attendance import struct import json def readall(_socket): # read all data from socket as defined in the header headerlength1 = _socket.recv(1) headerlength2 = _socket.recv(1) headerlength = struct.unpack( '>H', headerlength1 + headerlength2) # big endian format ...
0000Blaze/Smart-Attendance
teacherApp/server/client_teacher.py
import json import socket from typing import final from server import communication_json #from communication_json import convert2send, readall ATTENDANCE_SERVER = {'host': '127.0.0.1', 'port': 60001} #ATTENDANCE_SERVER = {'host': '192.168.1.65', 'port': 60001} #ATTENDANCE_SERVER = {'host': '192.168.152.108', 'port': ...
0000Blaze/Smart-Attendance
studentApp/main.py
import server.client_student import cv2 import face_recognition import os from kivy.core.window import Window from kivymd.app import MDApp from kivy.uix.camera import Camera from kivy.uix.image import Image from kivymd.uix.boxlayout import MDBoxLayout from kivymd.uix.button import MDFloatingActionButton, MDRaisedButt...
0000Blaze/Smart-Attendance
server/createdb.py
import mysql.connector def createdb(): host = 'localhost' user = 'root' password = '' port = 3306 dbname = 'sas' len_cid = 15 len_cname = 20 len_scode = 10 len_subname = 50 len_did = 10 len_dname = 100 len_tid = 10 len_tname = 50 len_sid = 15 len_sname = 50...
0000Blaze/Smart-Attendance
server/insertdb.py
<gh_stars>0 import mysql.connector dbinfo = {'host': 'localhost', 'user': 'root', 'password': '', 'port': 3306, 'database': 'sas'} def connect2db(_dbinfo=dbinfo): '''returns cursor to the mysql database mentioned in dbinfo dictionary''' mysqlconn = mysql.connector.conn...
0000Blaze/Smart-Attendance
studentApp/server/client_student.py
<filename>studentApp/server/client_student.py import json import socket import server.communication_json as communication_json # attendance_server = {'host': '127.0.0.1', 'port': 60000} attendance_server = {'host': '192.168.152.108', 'port': 60000} #attendance_server = {'host': '192.168.1.65', 'port': 60000} SERVER_TI...
0000Blaze/Smart-Attendance
server/server.py
<gh_stars>0 import socket import threading import random import sched import time import sys import numpy import face_recognition import mysql.connector import communication_json import insertdb import utility MAX_ACODE = 1000 # server info server_ip = '192.168.152.108' student_port = 60000 teac...
0000Blaze/Smart-Attendance
scraper/getStudentList.py
<filename>scraper/getStudentList.py from pydoc import source_synopsis from markupsafe import string import requests from requests import get from bs4 import BeautifulSoup import pandas as pd import numpy as np from recordHandler import splitClasses from recordHandler import addNewStudents from recordHandler import rem...
0000Blaze/Smart-Attendance
scraper/recordHandler.py
<reponame>0000Blaze/Smart-Attendance ## ONLY MODULES HERE IMPORTED IN getStudentList.py #made to handle the csv file #1. split classes AB and CD studnets #2. add the new transfer students #3. removed dropouts from itertools import count from operator import index from statistics import variance import pandas as pd fr...
0000Blaze/Smart-Attendance
server/utility.py
<filename>server/utility.py def getKey(dictionary, svalue): for key, value in dictionary.items(): if value == svalue: return key # def hasKey(dictionary, key): # if key in dictionary: # return True # return False
0000Blaze/Smart-Attendance
data/getStudentImages.py
import wget def imageDownloader(fixed_url,varying_url): try: url = fixed_url + varying_url + ".png" file_name = wget.download(url) except: try: url = fixed_url + varying_url + ".jpg" file_name = wget.download(url) except: url = fixed_url + va...
andrewzweb/TiShop
base_app/functional_tests/test_product_delete.py
<filename>base_app/functional_tests/test_product_delete.py<gh_stars>0 ''' functional test to delete product ''' from django.urls import reverse from mixer.backend.django import mixer import pytest from .base import FunctionalTest pytestmark = pytest.mark.django_db class ProductDeleteTest(FunctionalTest): """ tes...
andrewzweb/TiShop
base_app/product/migrations/0003_productimage_description.py
# Generated by Django 3.1.7 on 2021-03-23 17:00 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('product', '0002_productimage'), ] operations = [ migrations.AddField( model_name='productimage', name='description',...
andrewzweb/TiShop
base_app/product/tests/test_models.py
<reponame>andrewzweb/TiShop<filename>base_app/product/tests/test_models.py ''' Test product models ''' import decimal import pytest from django.utils.text import slugify from mixer.backend.django import mixer pytestmark = pytest.mark.django_db from ..models import ProductImage class TestProduct: ''' test product...
andrewzweb/TiShop
base_app/product/migrations/0006_auto_20210323_1711.py
# Generated by Django 3.1.7 on 2021-03-23 17:11 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('product', '0005_auto_20210323_1707'), ] operations = [ migrations.AlterField( model_name='productimage', name='image...
andrewzweb/TiShop
base_app/product/models.py
<reponame>andrewzweb/TiShop ''' product models ''' from django.db import models from django.utils.safestring import mark_safe from django.utils.text import slugify class Product(models.Model): ''' model product ''' title = models.CharField(max_length=250) slug = models.SlugField(blank=True, null=True) ...
andrewzweb/TiShop
base_app/functional_tests/test_product_list.py
''' functional test product detail ''' import pytest from django.urls import reverse from .base import FunctionalTest from mixer.backend.django import mixer pytestmark = pytest.mark.django_db import time class ProductListTest(FunctionalTest): """ testcase list product """ def setUp(self): ''' new set...
andrewzweb/TiShop
base_app/functional_tests/test_home_mock.py
from .base import FunctionalTest from django.urls import reverse import pytest class HomePageTest(FunctionalTest): """ testcase home view """ @pytest.mark.integration def test_get_home_page(self): ''' test get home page ''' self.browser.get( self.live_server_url + reverse('prod...
andrewzweb/TiShop
base_app/product/urls.py
from django.urls import path from . import views app_name='product' urlpatterns = [ path('home/', views.home, name='home'), path('add/', views.product_add, name='add'), path('', views.product_all, name='all'), path('<slug:product_slug>', views.product_detail, name='detail'), path('<slug:product_s...
andrewzweb/TiShop
base_app/product/views.py
from django.shortcuts import render, redirect, get_object_or_404 from django.urls import reverse from django.forms import modelformset_factory from .models import Product, ProductImage, Category from . import forms def home(request): ''' home ''' greatings = 'Hello you are at home' return render(request, ...
andrewzweb/TiShop
base_app/product/admin.py
<gh_stars>0 ''' admin product ''' from django.contrib import admin from . import models class ProductImagesInstanceInline(admin.TabularInline): model = models.ProductImage fields = ('small_image', 'description', 'image', 'product') readonly_fields = ('small_image',) extra = 1 @admin.register(models...
andrewzweb/TiShop
base_app/functional_tests/base.py
<filename>base_app/functional_tests/base.py ''' base module which use in functional tests''' from selenium import webdriver from django.contrib.staticfiles.testing import StaticLiveServerTestCase import time import os MAX_WAIT = 10 class FunctionalTest(StaticLiveServerTestCase): """ test new user """ def s...
andrewzweb/TiShop
base_app/base_app/test_settings.py
from .settings import * DATABASE = { "default":{ "ENGINE": 'django.db.backend.sqlite3', "NAME": 'memory', } } EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
andrewzweb/TiShop
base_app/product/migrations/0008_auto_20210323_1838.py
# Generated by Django 3.1.7 on 2021-03-23 18:38 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('product', '0007_productimage_product'), ] operations = [ migrations.CreateModel( name='Category...
andrewzweb/TiShop
base_app/functional_tests/test_product_update.py
''' functional test to update product ''' import os import time import pytest from django.urls import reverse from .base import FunctionalTest from selenium.webdriver.support.ui import Select from product import models class ProductUpdateTest(FunctionalTest): """ testcase update product """ def setUp(self):...
andrewzweb/TiShop
base_app/product/migrations/0004_productimage_image.py
<gh_stars>0 # Generated by Django 3.1.7 on 2021-03-23 17:06 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('product', '0003_productimage_description'), ] operations = [ migrations.AddField( model_name='productimage', ...
andrewzweb/TiShop
base_app/product/tests/test_views.py
''' test views ''' from faker import Faker import random import pytest from django.core.files.uploadedfile import SimpleUploadedFile from django.urls import reverse from django.test import RequestFactory from mixer.backend.django import mixer pytestmark = pytest.mark.django_db faker = Faker() from .. import views fro...
andrewzweb/TiShop
base_app/functional_tests/test_product_detail.py
<gh_stars>0 ''' functional test product detail ''' import pytest from django.urls import reverse from .base import FunctionalTest from mixer.backend.django import mixer pytestmark = pytest.mark.django_db class ProductDetailTest(FunctionalTest): """ testcase detail product """ def setUp(self): ''' ne...
brulato/python_conferearquivos
arquivos.py
from pathlib import Path import os.path #BUSCAR CAMINHO ATUAL DO SCRIPT mypath = Path().absolute() caminho = format(mypath) #CRIAR ARQUIVO DE LOG NomeLog = 'log.txt' CaminhoLog = caminho + '\\' + NomeLog gearararquivo = open(CaminhoLog, 'w', encoding='utf-8') #ABRIR ARQUIVO CONTENDO A RELAÇÃO DE NUMEROS ...
jgrundstad/KLC_tracker
klc/tracker/forms.py
from django import forms from django.forms import ModelForm from tracker.models import Item class ItemForm(ModelForm): class Meta: model = Item fields = ['proceeding', 'contacts', 'name', 'notes']
jgrundstad/KLC_tracker
klc/tracker/migrations/0005_auto_20150130_0136.py
<filename>klc/tracker/migrations/0005_auto_20150130_0136.py # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('tracker', '0004_auto_20150129_1836'), ] operations = [ migration...
jgrundstad/KLC_tracker
klc/tracker/migrations/0001_initial.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ] operations = [ migrations.CreateModel( name='Client', fields=[ ('id', models.AutoField(verbo...
jgrundstad/KLC_tracker
klc/tracker/admin.py
from django.contrib import admin from tracker.models import Proceeding, Contact, Item, Code class ProceedingAdmin(admin.ModelAdmin): list_display = ('name', 'contact', 'start_date') class ItemAdmin(admin.ModelAdmin): list_display = ('proceeding', 'date', 'name', 'snippet') def snippet(self, obj): return "%...
jgrundstad/KLC_tracker
klc/tracker/views.py
<gh_stars>0 from django.core.context_processors import csrf from django.core.urlresolvers import reverse from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render from forms import ItemForm from tracker.models import Proceeding, Contact, Item, Code # Create your views here. def in...
jgrundstad/KLC_tracker
klc/tracker/migrations/0013_auto_20150218_1949.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('tracker', '0012_auto_20150218_1939'), ] operations = [ migrations.RenameField( model_name='item', ol...
jgrundstad/KLC_tracker
klc/tracker/migrations/0012_auto_20150218_1939.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('tracker', '0011_auto_20150130_0207'), ] operations = [ migrations.CreateModel( name='Contact', field...
jgrundstad/KLC_tracker
klc/tracker/models.py
from django.db import models from django.forms import ModelForm # Create your models here. class Contact(models.Model): first_name = models.CharField(max_length=128, blank=True) last_name = models.CharField(max_length=128, blank=True) short_name = models.CharField(max_length=32, blank=True) role = models.Char...
jgrundstad/KLC_tracker
klc/tracker/urls.py
<gh_stars>0 from django.conf.urls import patterns, url from tracker import views urlpatterns = patterns('', url(r'^$', views.index, name='index'), url(r'^(?P<item_id>\d+)/item/$', views.item, name='item'), url(r'^(?P<contact_id>\d+)/contact/$', views.contact, name='contact'), url(r'^(?P<proceeding_id...
hillarykhan/DS-Unit-3-Sprint-2-SQL-and-Databases
module1-introduction-to-sql/test_queries.py
<reponame>hillarykhan/DS-Unit-3-Sprint-2-SQL-and-Databases import sqlite3 # STEP 1: Import library import sqlite3 from queries import TOTAL_SUBCLASS # STEP 2: Create a function to create the connection def connect_to_db(db_name="rpg_db.sqlite3"): return sqlite3.connect(db_name) def execute_query(cursor, query)...
hillarykhan/DS-Unit-3-Sprint-2-SQL-and-Databases
module1-introduction-to-sql/rpg_db_example.py
<filename>module1-introduction-to-sql/rpg_db_example.py<gh_stars>0 """SQL WORKFLOW EXAMPLE""" # STEP 1: Import library import sqlite3 # STEP 2: Create a function to create the connection def connect_to_db(db_name="rpg_db.sqlite3"): return sqlite3.connect(db_name) def execute_query(cursor, query): cursor.exe...
hillarykhan/DS-Unit-3-Sprint-2-SQL-and-Databases
module1-introduction-to-sql/buddymove_holidayiq.py
<reponame>hillarykhan/DS-Unit-3-Sprint-2-SQL-and-Databases import sqlite3 import pandas as pd buddymovie = pd.read_csv("./buddymove_holidayiq.csv") print(buddymovie.head()) # Open a connection to a new (blank) database file buddymove_holidayiq.sqlite3 conn = sqlite3.connect("buddymove_holidayiq.sqlite3") curs = con...
hillarykhan/DS-Unit-3-Sprint-2-SQL-and-Databases
module2-sql-for-analysis/lecture_notes.py
<gh_stars>0 import psycopg2 from psycopg2.extras import execute_values import json # Connect to ElephantSQL-hosted PostgresSQL # IMPORTANT: DO NOT COMMIT with credentials hard-coded # NEED TO SPECIFY CREDENTIALS WITH ENVIRONMENT VARIABLES # Example of what not to do in your .py: # DB_NAME = 'kvpmgnub' # DB_USER = 'kvp...
hydroshare/dockerspawner
dockerspawner/volumenamingstrategy.py
def default_format_volume_name(template, spawner): return template.format(username=spawner.user.name) def escaped_format_volume_name(label_template, spawner): """Use this strategy if your usernames include illegal characters for volume names and you do not use absolute paths in your volume label templa...
hydroshare/dockerspawner
dockerspawner/__init__.py
<filename>dockerspawner/__init__.py<gh_stars>1-10 from ._version import __version__ from .dockerspawner import DockerSpawner from .systemuserspawner import SystemUserSpawner __all__ = ['__version__', 'DockerSpawner', 'SystemUserSpawner']
hydroshare/dockerspawner
tests/volumes_test.py
"""Test volume manipulation logic """ from __future__ import absolute_import, division, print_function import types import pytest from traitlets.config import LoggingConfigurable def test_binds(monkeypatch): import jupyterhub monkeypatch.setattr("jupyterhub.spawner.Spawner", _MockSpawner) from dockerspaw...
outini/python-kairosdb
kairosdb/client.py
<reponame>outini/python-kairosdb # coding: utf-8 # # KairosDB REST API python client and interface (python-kairosdb) # # Copyright (C) 2017 <NAME> (jawa) <<EMAIL>> # # This file is part of python-kairosdb # # This program is free software; you can redistribute it and/or # modify it under the terms of the MIT Licen...
outini/python-kairosdb
kairosdb/__init__.py
<reponame>outini/python-kairosdb<gh_stars>1-10 # coding: utf-8 # # KairosDB REST API python client and interface (python-kairosdb) # # Copyright (C) 2017 <NAME> (jawa) <<EMAIL>> # # This file is part of python-kairosdb # # This program is free software; you can redistribute it and/or # modify it under the terms of...
outini/python-kairosdb
setup.py
# # Cachet API python client and interface (python-kairosdb) # # Copyright (C) 2017 <NAME> (jawa) <<EMAIL>> # # This file is part of python-kairosdb # # 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 Fre...
dmgav/dpcmaps
dpcmaps/dpc_gui.py
#!/usr/bin/env python """ Created on May 23, 2013 @author: <NAME> (<EMAIL>) Computer Science Group, Computational Science Center Brookhaven National Laboratory This code is for Differential Phase Contrast (DPC) imaging based on Fourier-shift fitting implementation. Reference: Yan, H. et al. Quantita...
dmgav/dpcmaps
dpcmaps/scan.py
import collections import numpy as np from databroker import DataBroker as db import logging logger = logging.getLogger(__name__) def _eval_scan_args(scan_args): """Evaluate scan arguments, replacing OphydObjects with NamedObjects""" class NamedObject: def __init__(self, name): self.nam...
dmgav/dpcmaps
dpcmaps/load_timepix.py
<gh_stars>0 import numpy as np import matplotlib.pyplot as plt # a = lt.load_tiff(36025, 256, 256, 512, 512, 2) def load(filename, nx_prb=256, ny_prb=256, x_raw=512, y_raw=512, threshold=0): diff_array = np.zeros((nx_prb, ny_prb)) if 1: with open(filename, "r") as f: np.fromfile(f, dtype...
dmgav/dpcmaps
dpcmaps/hxn_db.py
from hxntools.handlers import register import yaml from metadatastore.mds import MDS from databroker import Broker from filestore.fs import FileStore from hxntools.handlers.timepix import TimepixHDF5Handler # from hxntools.handlers.xspress3 import Xspress3HDF5Handler register() with open("/home/xf03id/.config/data...
dmgav/dpcmaps
dpcmaps/dpc_kernel.py
#!/usr/bin/env python """ Created on May 23, 2013 @author: <NAME> (<EMAIL>) Computer Science Group, Computational Science Center Brookhaven National Laboratory This code is for Differential Phase Contrast (DPC) imaging based on Fourier-shift fitting implementation. Reference: Yan, H. et al. Quantita...
dmgav/dpcmaps
dpcmaps/remove_ctrl_m_chars.py
import os import sys import tempfile def main(): filename = sys.argv[1] with tempfile.NamedTemporaryFile(delete=False) as fh: for line in open(filename): line = line.rstrip() fh.write(line + "\n") os.rename(filename, filename + ".bak") os.rename(fh.name, filenam...
dmgav/dpcmaps
dpcmaps/dpc.py
<filename>dpcmaps/dpc.py #!/usr/bin/env python """ Created on May 23, 2013, last modified on June 19, 2013 @author: <NAME> (<EMAIL>) Computer Science Group, Computational Science Center Brookhaven National Laboratory This code is for Differential Phase Contrast (DPC) imaging based on Fourier-shift fi...
dmgav/dpcmaps
dpcmaps/db_config/db_config.py
<filename>dpcmaps/db_config/db_config.py import json import os import platform beamline_name = "" # The following code is borrowed from PyXRF. It supposed to determine beamline name # based on PyXRF configuration file '/etc/pyxrf/pyxrf.json' try: beamline_name = "" # Attempt to find the configuration file...