コード例 #1
0
 def __init__(self):
     """ 
     Sets up the class and database objects.
     """
     self.__database = instance = db.Instance()
     self.__db = instance.db
     self.__id_gen = cuid.CuidGenerator()
     self.__allocation = {}
コード例 #2
0
ファイル: user.py プロジェクト: crablab/dissertation
    def __init__(self):
        """
        Instantiates user object.
        """

        self.__database = instance = db.Instance()
        self.__db = instance.db
        self.__ph = PasswordHasher()
        self.__id_gen = cuid.CuidGenerator()
        self.__user = {"object": None, "authenticated": False}
コード例 #3
0
 def setUp(self):
     self.generator = cuid.CuidGenerator()
コード例 #4
0
def course():
    idgen = cuid.CuidGenerator()
    return idgen.cuid()
コード例 #5
0
def email():
    id = cuid.CuidGenerator()
    return id.cuid() + "@live.rhul.ac.uk"
コード例 #6
0
def random_value():
    idgen = cuid.CuidGenerator()
    return idgen.cuid()
コード例 #7
0
ファイル: notify.py プロジェクト: crablab/hackney-ipp
import cuid, sys, os
from dotenv import load_dotenv
from notifications_python_client.notifications import NotificationsAPIClient

# Load .env
load_dotenv()

# Set up a new Notify client
notifications_client = NotificationsAPIClient(os.getenv("NOTIFY_KEY"))

# Generate a unique reference
id_gen = cuid.CuidGenerator()
id = id_gen.cuid()

# Get the file redirected to stdin (as a binary file)
input = sys.stdin.buffer.read()
with open(id, "wb") as output:
    output.write(input)

# Convert from PostScript to PDF (has the effect of stripping out PCL which Notify doesn't like)
os.system("ps2pdf {} {}.pdf".format(id, id))

# Try to send a letter
with open("{}.pdf".format(id), "rb") as file_to_send:
    notification = notifications_client.send_precompiled_letter_notification(
        reference=id, pdf_file=file_to_send)
    print(notification)

# Delete local files
os.remove(id)
os.remove("{}.pdf".format(id))