This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from subprocess import check_output | |
| from datetime import datetime | |
| ms_since_epoch = check_output([ | |
| "node", | |
| "-e", | |
| "console.log(require('moment')().valueOf())" | |
| ]) | |
| dt = datetime.fromtimestamp(float(ms_since_epoch) / 1000.0) | |
| print(ms_since_epoch) | |
| print(dt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3.7 | |
| # pytest -s test_subapps.py | |
| # pip install pytest aiohttp pytest-aiohttp | |
| from aiohttp import web | |
| import pytest | |
| def handle_1(request): | |
| return web.Response(text="OK 1") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from tarfile import TarFile, TarInfo, open as OpenTarfile | |
| from tempfile import NamedTemporaryFile, TemporaryDirectory | |
| import shutil | |
| file_data = [ | |
| (b'1239EAD09123FCC', "/data/local/tmp/me"), | |
| (b'aaaaaaaaaaaaaaa', "/data/local/tmp/a"), | |
| (b'bbbbbbbbbbbbbbb', "/data/local/tmp/b") | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| html { | |
| font-size: 100%; | |
| overflow-y: scroll; | |
| -webkit-text-size-adjust: 100%; | |
| -ms-text-size-adjust: 100%; | |
| } | |
| body { | |
| color: #444; | |
| font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Updated from these out of date docs. | |
| # https://pika.readthedocs.io/en/stable/examples/tornado_consumer.html | |
| from pika.adapters.tornado_connection import TornadoConnection | |
| import pika | |
| import logging | |
| import coloredlogs | |
| coloredlogs.install() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sqlalchemy import create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy import Column, Boolean, String | |
| from sqlalchemy.orm import sessionmaker | |
| engine = create_engine('sqlite:///:memory:', echo=True) | |
| session = sessionmaker(bind=engine)() | |
| Base = declarative_base() | |
| class User(Base): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sqlalchemy import create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy import Column, Boolean, String, String, Integer, ForeignKey | |
| from sqlalchemy.orm import sessionmaker | |
| from secrets import token_hex | |
| from json import dumps | |
| import graphene | |
| from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField | |
| from graphene.relay import Connection | |
| from collections import defaultdict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sqlalchemy import create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy import Column, String, Integer, ForeignKey | |
| from sqlalchemy.orm import relationship | |
| from sqlalchemy.orm import sessionmaker | |
| engine = create_engine('sqlite:///:memory:', echo=False) | |
| session = sessionmaker(bind=engine)() | |
| Base = declarative_base() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RoleInput(graphene.InputObjectType): | |
| role = String() | |
| class FilteredConnectionField(SQLAlchemyConnectionField): | |
| def __init__(self, type, input_type, *args, **kwargs): | |
| fields = {name: field.type() for name, field in input_type._meta.fields.items()} | |
| kwargs.update(fields) | |
| super().__init__(type, *args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## | |
| # Usage: | |
| # Run `docker-compose up` | |
| # Navigate to localhost:7100 in your browser | |
| version: "3.6" | |
| services: | |
| stf: | |
| image: openstf/stf | |
| command: bin/stf local |