未验证 提交 ebccee0d 编写于 作者: D Dan Bader 提交者: GitHub

Merge branch 'master' into bitwise-operators

version: 1
update_configs:
- package_manager: "python"
directory: "/requirements.txt"
update_schedule: "monthly"
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
:information_source: Please note that the best way to get support for Real Python courses & articles is to join one of our [weekly Office Hours calls](https://realpython.com/office-hours/) or in the [RP Community Slack](https://realpython.com/community/).
You can report issues and problems here, but we typically won't be able to provide 1:1 support outside the channels listed above.
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: monthly
open-pull-requests-limit: 10
allow:
- dependency-name: flake8
- dependency-name: black
......@@ -108,3 +108,6 @@ ENV/
# Mac
*.DS_Store
# VS Code workspace
*.code-workspace
\ No newline at end of file
# Real Python Materials
Bonus materials, exercises, and example projects for our [Python tutorials](https://realpython.com).
Bonus materials, exercises, and example projects for Real Python's [Python tutorials](https://realpython.com).
Build Status: [![CircleCI](https://circleci.com/gh/realpython/materials.svg?style=svg)](https://circleci.com/gh/realpython/materials)
## Running Code Style Checks
## Got a Question?
The best way to get support for Real Python courses & articles and code in this repository is to join one of our [weekly Office Hours calls](https://realpython.com/office-hours/) or to ask your question in the [RP Community Slack](https://realpython.com/community/).
Due to time constraints we cannot provide 1:1 support via GitHub. See you on Slack or on the next Office Hours call 🙂
## Adding Source Code & Sample Projects to This Repo (RP Contributors)
### Running Code Style Checks
We use [flake8](http://flake8.pycqa.org/en/latest/) and [black](https://github.com/ambv/black) to ensure a consistent code style for all of our sample code in this repository.
......@@ -15,7 +23,7 @@ $ flake8
$ black --check .
```
## Running Python Code Formatter
### Running Python Code Formatter
We're using a tool called [black](https://github.com/ambv/black) on this repo to ensure consistent formatting. On CI it runs in "check" mode to ensure any new files added to the repo are following PEP 8. If you see linter warnings that say something like "would reformat some_file.py" it means black disagrees with your formatting.
......
......@@ -14,12 +14,10 @@ RADIUS = 150
class Welcome(arcade.Window):
"""Our main welcome window
"""
"""Our main welcome window"""
def __init__(self):
"""Initialize the window
"""
"""Initialize the window"""
# Call the parent class constructor
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
......@@ -28,8 +26,7 @@ class Welcome(arcade.Window):
arcade.set_background_color(arcade.color.WHITE)
def on_draw(self):
"""Called whenever we need to draw our window
"""
"""Called whenever we need to draw our window"""
# Clear the screen and start drawing
arcade.start_render()
......
......@@ -13,12 +13,10 @@ SCREEN_TITLE = "Draw Shapes"
class Welcome(arcade.Window):
"""Our main welcome window
"""
"""Our main welcome window"""
def __init__(self):
"""Initialize the window
"""
"""Initialize the window"""
# Call the parent class constructor
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
......@@ -27,8 +25,7 @@ class Welcome(arcade.Window):
arcade.set_background_color(arcade.color.WHITE)
def on_draw(self):
"""Called whenever we need to draw our window
"""
"""Called whenever we need to draw our window"""
# Clear the screen and start drawing
arcade.start_render()
......
......@@ -41,8 +41,7 @@ class SpaceShooter(arcade.Window):
"""
def __init__(self, width: int, height: int, title: str):
"""Initialize the game
"""
"""Initialize the game"""
super().__init__(width, height, title)
# Setup the empty sprite lists
......@@ -51,8 +50,7 @@ class SpaceShooter(arcade.Window):
self.all_sprites = arcade.SpriteList()
def setup(self):
"""Get the game ready to play
"""
"""Get the game ready to play"""
# Set the background color
arcade.set_background_color(arcade.color.SKY_BLUE)
......@@ -236,8 +234,7 @@ class SpaceShooter(arcade.Window):
self.player.left = 0
def on_draw(self):
"""Draw all game objects
"""
"""Draw all game objects"""
arcade.start_render()
self.all_sprites.draw()
......
......@@ -8,7 +8,6 @@ attrs==18.1.0
certifi==2018.8.13
chardet==3.0.4
contextvars==2.3
flake8==3.5.0
h11==0.8.1
idna==2.7
immutables==0.6
......@@ -23,8 +22,6 @@ pathlib2==2.3.2
pluggy==0.7.1
py==1.6.0
pycodestyle==2.3.1
pyflakes==1.6.0
pylint==2.1.1
pytest==3.7.3
requests==2.19.1
six==1.11.0
......
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
.DS_Store
*.pyc
*.o
*.so
*.swp
*~
.coverage*
htmlcov/
foo.py
debug.log
db.sqlite3
logs/*
*.egg
*.eggs
*.egg-info
build/
dist/
docs/_build/
extras/sample_site/uploads/
extras/sample_site/db.sqlite3
.tox/
"""
ASGI config for Blog project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Blog.settings")
application = get_asgi_application()
"""
Django settings for Blog project.
Generated by 'django-admin startproject' using Django 3.0.7.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "9p2cpl%!f8a0tptz_85&dulu&!_ve=j_0s6-l4=tc-g!p-$whj"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"core",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
ROOT_URLCONF = "Blog.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
WSGI_APPLICATION = "Blog.wsgi.application"
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = []
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = "/static/"
from django.contrib import admin
from django.urls import path, include
from core import views as core_views
urlpatterns = [
path("admin/", admin.site.urls),
path("", core_views.listing, name="listing"),
path("view_blog/<int:blog_id>/", core_views.view_blog, name="view_blog"),
path("see_request/", core_views.see_request),
path("user_info/", core_views.user_info),
path("private_place/", core_views.private_place),
path("accounts/", include("django.contrib.auth.urls")),
path("staff_place/", core_views.staff_place),
path("add_messages/", core_views.add_messages),
]
"""
WSGI config for Blog project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Blog.settings")
application = get_wsgi_application()
from django.contrib import admin
from core.models import Blog
@admin.register(Blog)
class BlogAdmin(admin.ModelAdmin):
pass
from django.apps import AppConfig
class CoreConfig(AppConfig):
name = "core"
[{"model": "core.blog", "pk": 1, "fields": {"title": "Fruit", "content": "<p> Turns out, you can compare them: </p>\r\n\r\n<ul>\r\n <li>Apple</li>\r\n <li>Orange</li>\r\n</ul>"}}, {"model": "core.blog", "pk": 2, "fields": {"title": "I like airplanes", "content": "I prefer them to be very <i>fast</i>. I wish the Concorde still existed."}}]
\ No newline at end of file
# Generated by Django 3.0.7 on 2020-07-31 15:14
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="Blog",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("title", models.CharField(max_length=50)),
("content", models.TextField()),
],
),
]
from django.db import models
class Blog(models.Model):
title = models.CharField(max_length=50)
content = models.TextField()
from django.contrib import messages
from django.contrib.auth.decorators import login_required, user_passes_test
from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404
from core.models import Blog
def listing(request):
data = {
"blogs": Blog.objects.all(),
}
return render(request, "listing.html", data)
def view_blog(request, blog_id):
blog = get_object_or_404(Blog, id=blog_id)
data = {
"blog": blog,
}
return render(request, "view_blog.html", data)
def see_request(request):
text = f"""
Some attributes of the HttpRequest object:
scheme: {request.scheme}
path: {request.path}
method: {request.method}
GET: {request.GET}
user: {request.user}
"""
return HttpResponse(text, content_type="text/plain")
def user_info(request):
text = f"""
Selected HttpRequest.user attributes:
username: {request.user.username}
is_anonymous: {request.user.is_anonymous}
is_staff: {request.user.is_staff}
is_superuser: {request.user.is_superuser}
is_active: {request.user.is_active}
"""
return HttpResponse(text, content_type="text/plain")
@login_required
def private_place(request):
return HttpResponse("Shhh, members only!", content_type="text/plain")
@user_passes_test(lambda user: user.is_staff)
def staff_place(request):
return HttpResponse("Employees must wash hands", content_type="text/plain")
@login_required
def add_messages(request):
username = request.user.username
messages.add_message(request, messages.INFO, f"Hello {username}")
messages.add_message(request, messages.WARNING, "DANGER WILL ROBINSON")
return HttpResponse("Messages added", content_type="text/plain")
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Blog.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == "__main__":
main()
#!/bin/bash
find . -name "*.pyc" -exec rm {} \;
rm db.sqlite3
python manage.py makemigrations core
python manage.py migrate
python manage.py loaddata core
#!/bin/bash
python manage.py runserver
<html>
<body>
{% block content %}
{% endblock content %}
</body>
</html>
{% extends "base.html" %}
{% block content %}
<h1>Blog Listing</h1>
{% if messages %}
<ul class="messages" style="background-color:#ccc">
{% for message in messages %}
<li {% if message.tags %} class="{{ message.tags }}" {% endif %}>
{{ message }}
</li>
{% endfor %}
</ul>
{% endif %}
<ul>
{% for blog in blogs %}
<li> <a href="{% url 'view_blog' blog.id %}">{{blog.title}}</a> </li>
{% endfor %}
</ul>
{% endblock content %}
{% extends 'base.html' %}
{% block content %}
<h1>Login</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Login">
</form>
<a href="{% url 'listing' %}">All Blogs</a>
{% endblock %}
{% extends "base.html" %}
{% block content %}
<h1>{{blog.title}}</h1>
{{blog.content|safe}}
<hr/>
<a href="{% url 'listing' %}">All Blogs</a>
{% endblock content %}
# Get Started With Django Part 3: Django View Authorization, Code Examples
This folder contains the sample code for [Get Started With Django Part 3: Django View Authorization](https://realpython.com/django-view-authorization/).
The code was tested with Python 3.8 and Django 3.0.7. To install the same version, use:
python -m pip install -r requirements.txt
This tutorial uses the Django admin, and comes with some sample data. To get going you will need to run the following commands:
cd Blog
python manage.py migrate
python manage.py createsuperuser
python manage.py loaddata core.json
Once those commands are complete, you can run the Django development server:
python manage.py runserver
With the server running, visit `http://127.0.0.1:8000` in your web browser to see the results.
......@@ -90,7 +90,7 @@ def create(person):
else:
abort(
406,
"Peron with last name {lname} already exists".format(lname=lname),
"Person with last name {lname} already exists".format(lname=lname),
)
......
......@@ -7,7 +7,9 @@ import time
class Pipeline:
"""Class to allow a single element pipeline between producer and consumer.
"""
Class to allow a single element pipeline
between producer and consumer.
"""
def __init__(self):
......
......@@ -8,7 +8,9 @@ SENTINEL = object()
class Pipeline:
"""Class to allow a single element pipeline between producer and consumer.
"""
Class to allow a single element pipeline
between producer and consumer.
"""
def __init__(self):
......
# Use Sentiment Analysis With Python to Classify Reviews
Resources and materials for Real Python's [Use Sentiment Analysis With Python to Classify Reviews](https://realpython.com/use-sentiment-analysis-python-classify-movie-reviews/) tutorial.
## Installation
Create and activate a new virtual environment:
```shell
$ python -m venv .venv
$ source .venv/bin/activate
```
Install Python dependencies into the active virtual environment:
```shell
(.venv) $ python -m pip install -r requirements.txt
```
Download English model for spaCy:
```shell
(.venv) $ python -m spacy download en_core_web_sm
```
Download and extract the [Large Movie Review Dataset](https://ai.stanford.edu/~amaas/data/sentiment/) compiled by [Andrew Maas](http://www.andrew-maas.net/):
```shell
$ curl -s https://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz | tar xvz
```
## Usage
Get the sentiment of a movie review stored in the `TEST_REVIEW` variable:
```shell
(.venv) $ python sentiment_analyzer.py
```
import os
import random
import spacy
from spacy.util import minibatch, compounding
import pandas as pd
TEST_REVIEW = """
Transcendently beautiful in moments outside the office, it seems almost
sitcom-like in those scenes. When Toni Colette walks out and ponders
life silently, it's gorgeous.<br /><br />The movie doesn't seem to decide
whether it's slapstick, farce, magical realism, or drama, but the best of it
doesn't matter. (The worst is sort of tedious - like Office Space with less
humor.)
"""
eval_list = []
def train_model(
training_data: list, test_data: list, iterations: int = 20
) -> None:
# Build pipeline
nlp = spacy.load("en_core_web_sm")
if "textcat" not in nlp.pipe_names:
textcat = nlp.create_pipe(
"textcat", config={"architecture": "simple_cnn"}
)
nlp.add_pipe(textcat, last=True)
else:
textcat = nlp.get_pipe("textcat")
textcat.add_label("pos")
textcat.add_label("neg")
# Train only textcat
training_excluded_pipes = [
pipe for pipe in nlp.pipe_names if pipe != "textcat"
]
with nlp.disable_pipes(training_excluded_pipes):
optimizer = nlp.begin_training()
# Training loop
print("Beginning training")
print("Loss\tPrecision\tRecall\tF-score")
batch_sizes = compounding(
4.0, 32.0, 1.001
) # A generator that yields infinite series of input numbers
for i in range(iterations):
print(f"Training iteration {i}")
loss = {}
random.shuffle(training_data)
batches = minibatch(training_data, size=batch_sizes)
for batch in batches:
text, labels = zip(*batch)
nlp.update(text, labels, drop=0.2, sgd=optimizer, losses=loss)
with textcat.model.use_params(optimizer.averages):
evaluation_results = evaluate_model(
tokenizer=nlp.tokenizer,
textcat=textcat,
test_data=test_data,
)
print(
f"{loss['textcat']}\t{evaluation_results['precision']}"
f"\t{evaluation_results['recall']}"
f"\t{evaluation_results['f-score']}"
)
# Save model
with nlp.use_params(optimizer.averages):
nlp.to_disk("model_artifacts")
def evaluate_model(tokenizer, textcat, test_data: list) -> dict:
reviews, labels = zip(*test_data)
reviews = (tokenizer(review) for review in reviews)
true_positives = 0
false_positives = 1e-8 # Can't be 0 because of presence in denominator
true_negatives = 0
false_negatives = 1e-8
for i, review in enumerate(textcat.pipe(reviews)):
true_label = labels[i]["cats"]
for predicted_label, score in review.cats.items():
# Every cats dictionary includes both labels, you can get all
# the info you need with just the pos label
if predicted_label == "neg":
continue
if score >= 0.5 and true_label["pos"]:
true_positives += 1
elif score >= 0.5 and true_label["neg"]:
false_positives += 1
elif score < 0.5 and true_label["neg"]:
true_negatives += 1
elif score < 0.5 and true_label["pos"]:
false_negatives += 1
precision = true_positives / (true_positives + false_positives)
recall = true_positives / (true_positives + false_negatives)
if precision + recall == 0:
f_score = 0
else:
f_score = 2 * (precision * recall) / (precision + recall)
return {"precision": precision, "recall": recall, "f-score": f_score}
def test_model(input_data: str = TEST_REVIEW):
# Load saved trained model
loaded_model = spacy.load("model_artifacts")
# Generate prediction
parsed_text = loaded_model(input_data)
# Determine prediction to return
if parsed_text.cats["pos"] > parsed_text.cats["neg"]:
prediction = "Positive"
score = parsed_text.cats["pos"]
else:
prediction = "Negative"
score = parsed_text.cats["neg"]
print(
f"Review text: {input_data}\nPredicted sentiment: {prediction}"
f"\tScore: {score}"
)
def load_training_data(
data_directory: str = "aclImdb/train", split: float = 0.8, limit: int = 0
) -> tuple:
# Load from files
reviews = []
for label in ["pos", "neg"]:
labeled_directory = f"{data_directory}/{label}"
for review in os.listdir(labeled_directory):
if review.endswith(".txt"):
with open(f"{labeled_directory}/{review}") as f:
text = f.read()
text = text.replace("<br />", "\n\n")
if text.strip():
spacy_label = {
"cats": {
"pos": "pos" == label,
"neg": "neg" == label,
}
}
reviews.append((text, spacy_label))
random.shuffle(reviews)
if limit:
reviews = reviews[:limit]
split = int(len(reviews) * split)
return reviews[:split], reviews[split:]
if __name__ == "__main__":
train, test = load_training_data(limit=25)
print("Training model")
train_model(train, test)
df = pd.DataFrame(eval_list)
pd.DataFrame.plot(df)
print("Testing model")
test_model()
......@@ -48,7 +48,10 @@ for file_path in DATA_FOLDER.glob("quiz_*_grades.csv"):
# ------------------------
final_data = pd.merge(
roster, hw_exam_grades, left_index=True, right_index=True,
roster,
hw_exam_grades,
left_index=True,
right_index=True,
)
final_data = pd.merge(
final_data, quiz_grades, left_on="Email Address", right_index=True
......
......@@ -49,7 +49,10 @@ for file_path in DATA_FOLDER.glob("quiz_*_grades.csv"):
# ------------------------
final_data = pd.merge(
roster, hw_exam_grades, left_index=True, right_index=True,
roster,
hw_exam_grades,
left_index=True,
right_index=True,
)
final_data = pd.merge(
final_data, quiz_grades, left_on="Email Address", right_index=True
......
......@@ -49,7 +49,10 @@ for file_path in DATA_FOLDER.glob("quiz_*_grades.csv"):
# ------------------------
final_data = pd.merge(
roster, hw_exam_grades, left_index=True, right_index=True,
roster,
hw_exam_grades,
left_index=True,
right_index=True,
)
final_data = pd.merge(
final_data, quiz_grades, left_on="Email Address", right_index=True
......
......@@ -51,7 +51,10 @@ for file_path in DATA_FOLDER.glob("quiz_*_grades.csv"):
# ------------------------
final_data = pd.merge(
roster, hw_exam_grades, left_index=True, right_index=True,
roster,
hw_exam_grades,
left_index=True,
right_index=True,
)
final_data = pd.merge(
final_data, quiz_grades, left_on="Email Address", right_index=True
......
......@@ -43,7 +43,10 @@ for file_path in DATA_FOLDER.glob("quiz_*_grades.csv"):
quiz_grades = pd.concat([quiz_grades, quiz], axis=1)
final_data = pd.merge(
roster, hw_exam_grades, left_index=True, right_index=True,
roster,
hw_exam_grades,
left_index=True,
right_index=True,
)
final_data = pd.merge(
final_data, quiz_grades, left_on="Email Address", right_index=True
......
# Real Python - Python Bindings Sample Code Repo
This is the repo to accompany the [Python Bindings](https://realpython.com/python-bindings-overview/) article.
To be able to run the code, you must first install the requirements:
```console
$ python -m pip install -r requirements.txt
```
This should be done inside a virtual environment.
Once that is installed, you can use the invoke tool mentioned in the article to build and run the tests. See the tasks.py file or run invoke --list to get more details.
\ No newline at end of file
#!/usr/bin/env python3
# IDE might complain with "no module found" here, even when it exists
import cffi_example
if __name__ == "__main__":
......
float cmult(int int_param, float float_param);
#ifdef _MSC_VER
#define EXPORT_SYMBOL __declspec(dllexport)
#else
#define EXPORT_SYMBOL
#endif
EXPORT_SYMBOL float cmult(int int_param, float float_param);
\ No newline at end of file
#!/usr/bin/env python
""" Simple examples of calling C functions through ctypes module. """
import ctypes
import pathlib
import sys
if __name__ == "__main__":
# Load the shared library into c types.
libname = pathlib.Path().absolute() / "libcmult.so"
c_lib = ctypes.CDLL(libname)
if sys.platform.startswith("win"):
c_lib = ctypes.CDLL("cmult.dll")
else:
c_lib = ctypes.CDLL("libcmult.so")
# Sample data for our call:
x, y = 6, 2.3
......
""" Task definitions for invoke command line utility for python bindings
overview article. """
overview article.
"""
import cffi
import invoke
import pathlib
import sys
import os
import shutil
import re
import glob
on_win = sys.platform.startswith("win")
@invoke.task
def clean(c):
""" Remove any built objects """
for pattern in ["*.o", "*.so", "cffi_example* cython_wrapper.cpp"]:
c.run("rm -rf {}".format(pattern))
for file_pattern in (
"*.o",
"*.so",
"*.obj",
"*.dll",
"*.exp",
"*.lib",
"*.pyd",
"cffi_example*", # Is this a dir?
"cython_wrapper.cpp",
):
for file in glob.glob(file_pattern):
os.remove(file)
for dir_pattern in "Release":
for dir in glob.glob(dir_pattern):
shutil.rmtree(dir)
def print_banner(msg):
......@@ -17,32 +39,55 @@ def print_banner(msg):
print("= {} ".format(msg))
@invoke.task
def build_cmult(c):
@invoke.task()
def build_cmult(c, path=None):
""" Build the shared library for the sample C code """
print_banner("Building C Library")
invoke.run("gcc -c -Wall -Werror -fpic cmult.c -I /usr/include/python3.7")
invoke.run("gcc -shared -o libcmult.so cmult.o")
print("* Complete")
# Moving this type hint into signature causes an error (???)
c: invoke.Context
if on_win:
if not path:
print("Path is missing")
else:
# Using c.cd didn't work with paths that have spaces :/
path = f'"{path}vcvars32.bat" x86' # Enter the VS venv
path += f'&& cd "{os.getcwd()}"' # Change to current dir
path += "&& cl /LD cmult.c" # Compile
# Uncomment line below, to suppress stdout
# path = path.replace("&&", " >nul &&") + " >nul"
c.run(path)
else:
print_banner("Building C Library")
cmd = "gcc -c -Wall -Werror -fpic cmult.c -I /usr/include/python3.7"
invoke.run(cmd)
invoke.run("gcc -shared -o libcmult.so cmult.o")
print("* Complete")
@invoke.task(build_cmult)
@invoke.task()
def test_ctypes(c):
""" Run the script to test ctypes """
print_banner("Testing ctypes Module")
invoke.run("python3 ctypes_test.py", pty=True)
# pty and python3 didn't work for me (win).
if on_win:
invoke.run("python ctypes_test.py")
else:
invoke.run("python3 ctypes_test.py", pty=True)
@invoke.task(build_cmult)
@invoke.task()
def build_cffi(c):
""" Build the CFFI Python bindings """
print_banner("Building CFFI Module")
ffi = cffi.FFI()
this_dir = pathlib.Path().absolute()
this_dir = pathlib.Path().resolve()
h_file_name = this_dir / "cmult.h"
with open(h_file_name) as h_file:
ffi.cdef(h_file.read())
# cffi does not like our preprocessor directives, so we remove them
lns = h_file.read().splitlines()
flt = filter(lambda ln: not re.match(r" *#", ln), lns)
flt = map(lambda ln: ln.replace("EXPORT_SYMBOL ", ""), flt)
ffi.cdef(str("\n").join(flt))
ffi.set_source(
"cffi_example",
......@@ -66,7 +111,7 @@ def build_cffi(c):
def test_cffi(c):
""" Run the script to test CFFI """
print_banner("Testing CFFI Module")
invoke.run("python3 cffi_test.py", pty=True)
invoke.run("python cffi_test.py", pty=not on_win)
@invoke.task()
......
The MIT License (MIT)
Copyright (c) 2020 Leodanis Pozo Ramos
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.
# Sample PyQt Application
A sample GUI application that shows how to create and use menus, toolbars, and status bars using Python and PyQt.
## How to Run this Application
To run this application, you need to [install `PyQt5`](https://realpython.com/python-pyqt-gui-calculator/#installing-pyqt) on your Python environment. To do that, you can run the following commands in a terminal or command prompt:
```sh
$ pip3 install PyQt5
```
Once you have [PyQt](https://www.riverbankcomputing.com/static/Docs/PyQt5/) installed, you can run the application by executing the following command:
```sh
$ python3 sample-app.py
```
This command will launch the application, so you'll be able to experiment with it.
## About the Author
Leodanis Pozo Ramos – [@lpozo78](https://twitter.com/lpozo78) – lpozor78@gmail.com
## License
- This application is distributed under the MIT license. See `LICENSE` for details.
- The set of icons used in this application are part of the [TurkinOS](https://github.com/llamaret/turkinos-icon) icon theme, which is distributed under the [GPL v3.0 license](https://github.com/llamaret/turkinos-icon/blob/master/LICENSE). See `resources/LICENSE` for details.
\ No newline at end of file
# -*- coding: utf-8 -*-
# Resource object code
#
# Created by: The Resource Compiler for PyQt5 (Qt v5.9.5)
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore
qt_resource_data = b"\
\x00\x00\x03\xb1\
\x3c\
\x73\x76\x67\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\
\x30\x2f\x73\x76\x67\x22\x20\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\
\x30\x20\x30\x20\x32\x32\x20\x32\x32\x22\x3e\x0a\x20\x3c\x64\x65\
\x66\x73\x20\x69\x64\x3d\x22\x64\x65\x66\x73\x33\x30\x35\x31\x22\
\x3e\x0a\x20\x20\x20\x3c\x73\x74\x79\x6c\x65\x20\x74\x79\x70\x65\
\x3d\x22\x74\x65\x78\x74\x2f\x63\x73\x73\x22\x20\x69\x64\x3d\x22\
\x63\x75\x72\x72\x65\x6e\x74\x2d\x63\x6f\x6c\x6f\x72\x2d\x73\x63\
\x68\x65\x6d\x65\x22\x3e\x0a\x20\x20\x20\x20\x20\x2e\x43\x6f\x6c\
\x6f\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x20\x7b\x0a\
\x20\x20\x20\x20\x20\x20\x20\x63\x6f\x6c\x6f\x72\x3a\x23\x34\x64\
\x34\x64\x34\x64\x3b\x0a\x20\x20\x20\x20\x20\x7d\x0a\x20\x20\x20\
\x20\x20\x3c\x2f\x73\x74\x79\x6c\x65\x3e\x0a\x20\x3c\x2f\x64\x65\
\x66\x73\x3e\x0a\x20\x20\x20\x3c\x70\x61\x74\x68\x0a\x20\x20\x20\
\x20\x20\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x63\
\x75\x72\x72\x65\x6e\x74\x43\x6f\x6c\x6f\x72\x3b\x66\x69\x6c\x6c\
\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x31\x3b\x73\x74\x72\x6f\x6b\
\x65\x3a\x6e\x6f\x6e\x65\x22\x0a\x20\x20\x20\x20\x20\x20\x64\x3d\
\x22\x6d\x31\x34\x2e\x39\x39\x39\x39\x39\x33\x20\x36\x2e\x30\x30\
\x30\x30\x30\x31\x37\x68\x2d\x31\x30\x2e\x39\x39\x39\x39\x38\x38\
\x63\x2d\x2e\x35\x35\x32\x30\x30\x34\x38\x20\x30\x2d\x31\x2e\x30\
\x30\x30\x30\x30\x35\x2e\x34\x34\x38\x30\x30\x30\x32\x2d\x31\x2e\
\x30\x30\x30\x30\x30\x35\x2e\x39\x39\x39\x39\x39\x31\x36\x76\x31\
\x31\x2e\x30\x30\x30\x30\x30\x31\x37\x63\x30\x20\x2e\x35\x35\x32\
\x30\x30\x35\x2e\x34\x34\x38\x30\x30\x30\x32\x20\x31\x2e\x30\x30\
\x30\x30\x30\x35\x20\x31\x2e\x30\x30\x30\x30\x30\x35\x20\x31\x2e\
\x30\x30\x30\x30\x30\x35\x68\x31\x30\x2e\x39\x39\x39\x39\x38\x38\
\x63\x2e\x35\x35\x32\x30\x30\x35\x20\x30\x20\x31\x2e\x30\x30\x30\
\x30\x30\x35\x2d\x2e\x34\x34\x38\x20\x31\x2e\x30\x30\x30\x30\x30\
\x35\x2d\x31\x2e\x30\x30\x30\x30\x30\x35\x76\x2d\x31\x31\x2e\x30\
\x30\x30\x30\x30\x31\x37\x63\x30\x2d\x2e\x35\x35\x31\x39\x39\x31\
\x34\x2d\x2e\x34\x34\x38\x2d\x2e\x39\x39\x39\x39\x39\x31\x36\x2d\
\x31\x2e\x30\x30\x30\x30\x30\x35\x2d\x2e\x39\x39\x39\x39\x39\x31\
\x36\x7a\x6d\x33\x2e\x30\x30\x30\x30\x30\x32\x2d\x33\x2e\x30\x30\
\x30\x30\x30\x31\x37\x68\x2d\x39\x2e\x39\x39\x39\x39\x39\x36\x37\
\x63\x2d\x2e\x35\x35\x32\x30\x30\x34\x38\x20\x30\x2d\x31\x2e\x30\
\x30\x30\x30\x30\x35\x2e\x34\x34\x38\x30\x30\x30\x32\x2d\x31\x2e\
\x30\x30\x30\x30\x30\x35\x20\x31\x2e\x30\x30\x30\x30\x30\x35\x76\
\x2e\x39\x39\x39\x39\x39\x31\x36\x68\x31\x2e\x30\x30\x30\x30\x30\
\x35\x76\x2d\x2e\x35\x30\x30\x30\x30\x32\x35\x63\x30\x2d\x2e\x32\
\x37\x35\x39\x39\x35\x37\x2e\x32\x32\x34\x30\x30\x36\x38\x2d\x2e\
\x34\x39\x39\x39\x38\x39\x31\x2e\x35\x30\x30\x30\x30\x32\x35\x2d\
\x2e\x34\x39\x39\x39\x38\x39\x31\x68\x38\x2e\x39\x39\x39\x39\x39\
\x31\x32\x63\x2e\x32\x37\x36\x30\x31\x20\x30\x20\x2e\x35\x30\x30\
\x30\x30\x33\x2e\x32\x32\x33\x39\x39\x33\x34\x2e\x35\x30\x30\x30\
\x30\x33\x2e\x34\x39\x39\x39\x38\x39\x31\x76\x39\x2e\x30\x30\x30\
\x30\x30\x34\x39\x63\x30\x20\x2e\x32\x37\x35\x39\x39\x36\x2d\x2e\
\x32\x32\x33\x39\x39\x33\x2e\x35\x30\x30\x30\x30\x33\x2d\x2e\x35\
\x30\x30\x30\x30\x33\x2e\x35\x30\x30\x30\x30\x33\x68\x2d\x2e\x34\
\x39\x39\x39\x38\x39\x76\x2e\x39\x39\x39\x39\x39\x31\x68\x2e\x39\
\x39\x39\x39\x39\x32\x63\x2e\x35\x35\x32\x30\x30\x35\x20\x30\x20\
\x31\x2e\x30\x30\x30\x30\x30\x35\x2d\x2e\x34\x34\x38\x20\x31\x2e\
\x30\x30\x30\x30\x30\x35\x2d\x2e\x39\x39\x39\x39\x39\x31\x76\x2d\
\x39\x2e\x39\x39\x39\x39\x39\x37\x63\x30\x2d\x2e\x35\x35\x32\x30\
\x30\x34\x38\x2d\x2e\x34\x34\x38\x2d\x31\x2e\x30\x30\x30\x30\x30\
\x35\x2d\x31\x2e\x30\x30\x30\x30\x30\x35\x2d\x31\x2e\x30\x30\x30\
\x30\x30\x35\x7a\x22\x0a\x20\x20\x20\x20\x20\x20\x63\x6c\x61\x73\
\x73\x3d\x22\x43\x6f\x6c\x6f\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\
\x65\x78\x74\x22\x20\x2f\x3e\x0a\x3c\x2f\x73\x76\x67\x3e\x20\x0a\
\
\x00\x00\x02\xfb\
\x3c\
\x73\x76\x67\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\
\x30\x2f\x73\x76\x67\x22\x20\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\
\x30\x20\x30\x20\x32\x32\x20\x32\x32\x22\x3e\x0a\x20\x3c\x64\x65\
\x66\x73\x20\x69\x64\x3d\x22\x64\x65\x66\x73\x33\x30\x35\x31\x22\
\x3e\x0a\x20\x20\x20\x3c\x73\x74\x79\x6c\x65\x20\x74\x79\x70\x65\
\x3d\x22\x74\x65\x78\x74\x2f\x63\x73\x73\x22\x20\x69\x64\x3d\x22\
\x63\x75\x72\x72\x65\x6e\x74\x2d\x63\x6f\x6c\x6f\x72\x2d\x73\x63\
\x68\x65\x6d\x65\x22\x3e\x0a\x20\x20\x20\x20\x20\x2e\x43\x6f\x6c\
\x6f\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x20\x7b\x0a\
\x20\x20\x20\x20\x20\x20\x20\x63\x6f\x6c\x6f\x72\x3a\x23\x34\x64\
\x34\x64\x34\x64\x3b\x0a\x20\x20\x20\x20\x20\x7d\x0a\x20\x20\x20\
\x20\x20\x3c\x2f\x73\x74\x79\x6c\x65\x3e\x0a\x20\x3c\x2f\x64\x65\
\x66\x73\x3e\x0a\x20\x20\x20\x3c\x70\x61\x74\x68\x0a\x20\x20\x20\
\x20\x20\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x63\
\x75\x72\x72\x65\x6e\x74\x43\x6f\x6c\x6f\x72\x3b\x66\x69\x6c\x6c\
\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x31\x3b\x73\x74\x72\x6f\x6b\
\x65\x3a\x6e\x6f\x6e\x65\x22\x0a\x20\x20\x20\x20\x20\x20\x64\x3d\
\x22\x6d\x31\x34\x2e\x31\x32\x36\x36\x32\x20\x38\x2e\x30\x30\x35\
\x32\x31\x68\x2d\x2e\x39\x34\x35\x32\x76\x2d\x32\x2e\x32\x32\x39\
\x33\x35\x63\x30\x2d\x2e\x32\x33\x32\x39\x34\x2d\x2e\x31\x38\x38\
\x31\x35\x2d\x2e\x34\x32\x31\x37\x2d\x2e\x34\x32\x30\x31\x34\x2d\
\x2e\x34\x32\x31\x37\x68\x2d\x2e\x34\x35\x32\x37\x33\x6c\x2d\x2e\
\x39\x30\x35\x38\x39\x2d\x33\x2e\x30\x35\x32\x39\x63\x2d\x2e\x30\
\x35\x33\x2d\x2e\x31\x37\x38\x37\x31\x2d\x2e\x32\x31\x36\x37\x39\
\x2d\x2e\x33\x30\x31\x32\x36\x2d\x2e\x34\x30\x32\x36\x36\x2d\x2e\
\x33\x30\x31\x32\x36\x2d\x2e\x31\x38\x35\x37\x38\x20\x30\x2d\x2e\
\x33\x34\x39\x36\x33\x2e\x31\x32\x32\x35\x35\x2d\x2e\x34\x30\x32\
\x36\x36\x2e\x33\x30\x31\x32\x36\x6c\x2d\x2e\x39\x30\x35\x38\x39\
\x20\x33\x2e\x30\x35\x32\x39\x68\x2d\x2e\x34\x35\x32\x37\x33\x63\
\x2d\x2e\x32\x33\x31\x39\x39\x20\x30\x2d\x2e\x34\x32\x30\x31\x34\
\x2e\x31\x38\x38\x37\x36\x2d\x2e\x34\x32\x30\x31\x34\x2e\x34\x32\
\x31\x37\x76\x32\x2e\x32\x32\x39\x34\x32\x68\x2d\x2e\x39\x34\x35\
\x32\x63\x2d\x31\x2e\x30\x33\x32\x39\x35\x20\x30\x2d\x31\x2e\x38\
\x37\x33\x33\x38\x2e\x38\x34\x33\x34\x38\x2d\x31\x2e\x38\x37\x33\
\x33\x38\x20\x31\x2e\x38\x38\x30\x33\x35\x76\x38\x2e\x32\x33\x34\
\x30\x33\x63\x30\x20\x31\x2e\x30\x33\x36\x38\x36\x2e\x38\x34\x30\
\x33\x35\x20\x31\x2e\x38\x38\x30\x33\x34\x20\x31\x2e\x38\x37\x33\
\x33\x38\x20\x31\x2e\x38\x38\x30\x33\x34\x68\x36\x2e\x32\x35\x33\
\x32\x34\x63\x31\x2e\x30\x33\x32\x39\x35\x20\x30\x20\x31\x2e\x38\
\x37\x33\x33\x38\x2d\x2e\x38\x34\x33\x34\x38\x20\x31\x2e\x38\x37\
\x33\x33\x38\x2d\x31\x2e\x38\x38\x30\x33\x34\x76\x2d\x38\x2e\x32\
\x33\x34\x30\x33\x63\x30\x2d\x31\x2e\x30\x33\x36\x39\x36\x2d\x2e\
\x38\x34\x30\x33\x35\x2d\x31\x2e\x38\x38\x30\x34\x32\x2d\x31\x2e\
\x38\x37\x33\x33\x38\x2d\x31\x2e\x38\x38\x30\x34\x32\x7a\x22\x0a\
\x20\x20\x20\x20\x20\x20\x63\x6c\x61\x73\x73\x3d\x22\x43\x6f\x6c\
\x6f\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x22\x20\x2f\
\x3e\x0a\x3c\x2f\x73\x76\x67\x3e\x20\x0a\
\x00\x00\x06\xc6\
\x3c\
\x73\x76\x67\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\
\x30\x2f\x73\x76\x67\x22\x20\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\
\x30\x20\x30\x20\x32\x32\x20\x32\x32\x22\x3e\x0a\x20\x3c\x64\x65\
\x66\x73\x20\x69\x64\x3d\x22\x64\x65\x66\x73\x33\x30\x35\x31\x22\
\x3e\x0a\x20\x20\x20\x3c\x73\x74\x79\x6c\x65\x20\x74\x79\x70\x65\
\x3d\x22\x74\x65\x78\x74\x2f\x63\x73\x73\x22\x20\x69\x64\x3d\x22\
\x63\x75\x72\x72\x65\x6e\x74\x2d\x63\x6f\x6c\x6f\x72\x2d\x73\x63\
\x68\x65\x6d\x65\x22\x3e\x0a\x20\x20\x20\x20\x20\x2e\x43\x6f\x6c\
\x6f\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x20\x7b\x0a\
\x20\x20\x20\x20\x20\x20\x20\x63\x6f\x6c\x6f\x72\x3a\x23\x34\x64\
\x34\x64\x34\x64\x3b\x0a\x20\x20\x20\x20\x20\x7d\x0a\x20\x20\x20\
\x20\x20\x3c\x2f\x73\x74\x79\x6c\x65\x3e\x0a\x20\x3c\x2f\x64\x65\
\x66\x73\x3e\x0a\x20\x20\x20\x3c\x70\x61\x74\x68\x0a\x20\x20\x20\
\x20\x20\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x63\
\x75\x72\x72\x65\x6e\x74\x43\x6f\x6c\x6f\x72\x3b\x66\x69\x6c\x6c\
\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x31\x3b\x73\x74\x72\x6f\x6b\
\x65\x3a\x6e\x6f\x6e\x65\x22\x0a\x20\x20\x20\x20\x20\x20\x64\x3d\
\x22\x6d\x37\x2e\x30\x31\x33\x36\x37\x31\x39\x20\x32\x2d\x2e\x34\
\x33\x35\x35\x34\x36\x39\x2e\x37\x37\x35\x33\x39\x30\x36\x63\x2d\
\x2e\x32\x36\x39\x39\x32\x33\x31\x2e\x34\x38\x31\x32\x36\x36\x37\
\x2d\x2e\x35\x30\x33\x38\x36\x39\x34\x2e\x37\x30\x38\x37\x38\x39\
\x31\x2d\x2e\x36\x32\x38\x39\x30\x36\x32\x20\x31\x2e\x31\x33\x36\
\x37\x31\x38\x38\x2d\x2e\x30\x36\x32\x35\x31\x38\x35\x2e\x32\x31\
\x33\x39\x36\x34\x37\x2d\x2e\x30\x36\x31\x32\x35\x38\x34\x2e\x34\
\x36\x39\x39\x32\x32\x36\x2e\x30\x30\x31\x39\x35\x33\x31\x2e\x37\
\x30\x31\x31\x37\x31\x38\x2e\x30\x36\x33\x32\x31\x37\x31\x2e\x32\
\x33\x31\x32\x34\x39\x34\x2e\x31\x37\x32\x36\x32\x38\x35\x2e\x34\
\x35\x32\x37\x39\x38\x31\x2e\x33\x32\x36\x31\x37\x31\x39\x2e\x37\
\x32\x36\x35\x36\x32\x36\x6c\x33\x2e\x33\x39\x34\x35\x33\x31\x32\
\x20\x36\x2e\x30\x36\x32\x35\x30\x30\x32\x2d\x31\x2e\x37\x31\x34\
\x38\x34\x33\x38\x20\x33\x2e\x30\x32\x33\x34\x33\x37\x63\x2d\x2e\
\x34\x34\x38\x33\x36\x31\x36\x2d\x2e\x32\x37\x37\x34\x36\x31\x2d\
\x2e\x38\x39\x31\x31\x37\x33\x37\x2d\x2e\x35\x39\x31\x37\x39\x37\
\x2d\x31\x2e\x34\x35\x35\x30\x37\x38\x31\x2d\x2e\x35\x39\x31\x37\
\x39\x37\x2d\x31\x2e\x36\x35\x38\x32\x38\x36\x35\x20\x30\x2d\x33\
\x2e\x30\x30\x31\x39\x35\x33\x31\x20\x31\x2e\x33\x38\x38\x39\x37\
\x35\x2d\x33\x2e\x30\x30\x31\x39\x35\x33\x31\x20\x33\x2e\x30\x38\
\x33\x39\x38\x35\x20\x30\x20\x31\x2e\x36\x39\x35\x30\x30\x38\x20\
\x31\x2e\x33\x34\x33\x36\x36\x36\x33\x20\x33\x2e\x30\x38\x32\x30\
\x33\x31\x20\x33\x2e\x30\x30\x31\x39\x35\x33\x31\x20\x33\x2e\x30\
\x38\x32\x30\x33\x31\x20\x31\x2e\x36\x35\x38\x32\x38\x37\x20\x30\
\x20\x33\x2e\x30\x30\x31\x39\x35\x33\x32\x2d\x31\x2e\x33\x38\x37\
\x30\x32\x33\x20\x33\x2e\x30\x30\x31\x39\x35\x33\x31\x2d\x33\x2e\
\x30\x38\x32\x30\x33\x31\x20\x30\x2d\x2e\x31\x33\x33\x39\x35\x35\
\x2d\x2e\x30\x32\x30\x39\x38\x32\x34\x2d\x2e\x32\x35\x39\x33\x36\
\x33\x2d\x2e\x30\x33\x37\x31\x30\x39\x33\x2d\x2e\x33\x38\x36\x37\
\x31\x39\x2e\x34\x36\x32\x32\x34\x38\x34\x2d\x31\x2e\x30\x30\x33\
\x35\x36\x39\x2e\x38\x39\x38\x35\x34\x31\x31\x2d\x31\x2e\x37\x38\
\x38\x36\x32\x37\x20\x31\x2e\x38\x30\x38\x35\x39\x34\x31\x2d\x32\
\x2e\x32\x34\x38\x30\x34\x37\x2e\x30\x30\x33\x30\x33\x37\x2d\x2e\
\x30\x30\x33\x33\x37\x35\x2e\x30\x30\x32\x39\x33\x34\x2d\x2e\x30\
\x30\x34\x34\x33\x37\x2e\x30\x30\x35\x38\x35\x39\x2d\x2e\x30\x30\
\x37\x38\x31\x32\x6c\x31\x2e\x32\x35\x33\x39\x30\x36\x20\x32\x2e\
\x32\x33\x38\x32\x38\x31\x63\x2d\x2e\x30\x31\x37\x32\x32\x33\x2e\
\x31\x33\x34\x30\x33\x34\x2d\x2e\x30\x33\x39\x30\x36\x32\x2e\x32\
\x36\x35\x38\x30\x31\x2d\x2e\x30\x33\x39\x30\x36\x32\x2e\x34\x30\
\x34\x32\x39\x37\x20\x30\x20\x31\x2e\x36\x39\x35\x30\x30\x38\x20\
\x31\x2e\x33\x34\x33\x36\x36\x35\x20\x33\x2e\x30\x38\x32\x30\x33\
\x31\x20\x33\x2e\x30\x30\x31\x39\x35\x33\x20\x33\x2e\x30\x38\x32\
\x30\x33\x31\x20\x31\x2e\x36\x35\x38\x32\x38\x37\x20\x30\x20\x33\
\x2e\x30\x30\x31\x39\x35\x33\x2d\x31\x2e\x33\x38\x37\x30\x32\x33\
\x20\x33\x2e\x30\x30\x31\x39\x35\x33\x2d\x33\x2e\x30\x38\x32\x30\
\x33\x31\x20\x30\x2d\x31\x2e\x36\x39\x35\x30\x31\x2d\x31\x2e\x33\
\x34\x33\x36\x36\x37\x2d\x33\x2e\x30\x38\x33\x39\x38\x35\x2d\x33\
\x2e\x30\x30\x31\x39\x35\x33\x2d\x33\x2e\x30\x38\x33\x39\x38\x35\
\x2d\x2e\x35\x36\x31\x37\x36\x20\x30\x2d\x31\x2e\x30\x30\x34\x34\
\x31\x32\x2e\x33\x30\x38\x35\x34\x33\x2d\x31\x2e\x34\x35\x31\x31\
\x37\x32\x2e\x35\x38\x33\x39\x38\x35\x6c\x2d\x31\x2e\x37\x30\x38\
\x39\x38\x34\x2d\x33\x2e\x30\x31\x35\x36\x32\x35\x20\x33\x2e\x33\
\x39\x38\x34\x33\x37\x2d\x36\x2e\x30\x36\x32\x35\x30\x30\x32\x76\
\x2d\x2e\x30\x30\x31\x39\x35\x33\x32\x63\x2e\x31\x35\x32\x39\x33\
\x34\x2d\x2e\x32\x37\x32\x38\x31\x39\x33\x2e\x32\x36\x31\x31\x35\
\x39\x2d\x2e\x34\x39\x33\x39\x33\x39\x37\x2e\x33\x32\x34\x32\x31\
\x39\x2d\x2e\x37\x32\x34\x36\x30\x39\x34\x2e\x30\x36\x33\x32\x31\
\x34\x2d\x2e\x32\x33\x31\x32\x34\x39\x32\x2e\x30\x36\x36\x33\x33\
\x32\x2d\x2e\x34\x38\x37\x32\x30\x37\x31\x2e\x30\x30\x33\x39\x30\
\x36\x2d\x2e\x37\x30\x31\x31\x37\x31\x38\x2d\x2e\x31\x32\x35\x31\
\x33\x38\x2d\x2e\x34\x32\x37\x38\x38\x38\x32\x2d\x2e\x33\x35\x38\
\x39\x38\x34\x2d\x2e\x36\x35\x35\x34\x35\x32\x31\x2d\x2e\x36\x32\
\x38\x39\x30\x36\x2d\x31\x2e\x31\x33\x36\x37\x31\x38\x38\x6c\x2d\
\x2e\x34\x33\x35\x35\x34\x37\x2d\x2e\x37\x37\x35\x33\x39\x30\x36\
\x2d\x33\x2e\x39\x39\x34\x31\x34\x31\x20\x37\x2e\x30\x34\x38\x38\
\x32\x38\x31\x7a\x6d\x2d\x2e\x35\x31\x31\x37\x31\x38\x38\x20\x31\
\x33\x2e\x38\x38\x34\x37\x36\x36\x63\x2e\x35\x35\x36\x34\x30\x37\
\x38\x20\x30\x20\x2e\x39\x39\x36\x30\x39\x33\x38\x2e\x34\x34\x38\
\x34\x30\x31\x2e\x39\x39\x36\x30\x39\x33\x38\x20\x31\x2e\x30\x33\
\x33\x32\x30\x33\x73\x2d\x2e\x34\x33\x39\x36\x38\x36\x20\x31\x2e\
\x30\x33\x31\x32\x35\x2d\x2e\x39\x39\x36\x30\x39\x33\x38\x20\x31\
\x2e\x30\x33\x31\x32\x35\x2d\x2e\x39\x39\x34\x31\x34\x30\x36\x2d\
\x2e\x34\x34\x36\x34\x34\x38\x2d\x2e\x39\x39\x34\x31\x34\x30\x36\
\x2d\x31\x2e\x30\x33\x31\x32\x35\x63\x30\x2d\x2e\x35\x38\x34\x38\
\x30\x33\x2e\x34\x33\x37\x37\x33\x32\x38\x2d\x31\x2e\x30\x33\x33\
\x32\x30\x33\x2e\x39\x39\x34\x31\x34\x30\x36\x2d\x31\x2e\x30\x33\
\x33\x32\x30\x33\x7a\x6d\x38\x2e\x39\x39\x36\x30\x39\x33\x39\x20\
\x30\x63\x20\x2e\x35\x35\x36\x34\x30\x37\x20\x30\x20\x2e\x39\x39\
\x34\x31\x34\x2e\x34\x34\x38\x34\x30\x31\x2e\x39\x39\x34\x31\x34\
\x31\x20\x31\x2e\x30\x33\x33\x32\x30\x33\x20\x30\x20\x2e\x35\x38\
\x34\x38\x30\x32\x2d\x2e\x34\x33\x37\x37\x33\x34\x20\x31\x2e\x30\
\x33\x31\x32\x35\x2d\x2e\x39\x39\x34\x31\x34\x31\x20\x31\x2e\x30\
\x33\x31\x32\x35\x2d\x2e\x35\x35\x36\x34\x30\x39\x20\x30\x2d\x2e\
\x39\x39\x36\x30\x39\x34\x2d\x2e\x34\x34\x36\x34\x34\x38\x2d\x2e\
\x39\x39\x36\x30\x39\x34\x2d\x31\x2e\x30\x33\x31\x32\x35\x20\x30\
\x2d\x2e\x35\x38\x34\x38\x30\x33\x2e\x34\x33\x39\x36\x38\x35\x2d\
\x31\x2e\x30\x33\x33\x32\x30\x33\x2e\x39\x39\x36\x30\x39\x34\x2d\
\x31\x2e\x30\x33\x33\x32\x30\x33\x7a\x22\x0a\x20\x20\x20\x20\x20\
\x20\x63\x6c\x61\x73\x73\x3d\x22\x43\x6f\x6c\x6f\x72\x53\x63\x68\
\x65\x6d\x65\x2d\x54\x65\x78\x74\x22\x20\x2f\x3e\x0a\x3c\x2f\x73\
\x76\x67\x3e\x20\x0a\
\x00\x00\x02\xc8\
\x3c\
\x73\x76\x67\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\
\x30\x2f\x73\x76\x67\x22\x20\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\
\x30\x20\x30\x20\x32\x32\x20\x32\x32\x22\x3e\x0a\x20\x3c\x64\x65\
\x66\x73\x20\x69\x64\x3d\x22\x64\x65\x66\x73\x33\x30\x35\x31\x22\
\x3e\x0a\x20\x20\x20\x3c\x73\x74\x79\x6c\x65\x20\x74\x79\x70\x65\
\x3d\x22\x74\x65\x78\x74\x2f\x63\x73\x73\x22\x20\x69\x64\x3d\x22\
\x63\x75\x72\x72\x65\x6e\x74\x2d\x63\x6f\x6c\x6f\x72\x2d\x73\x63\
\x68\x65\x6d\x65\x22\x3e\x0a\x20\x20\x20\x20\x20\x2e\x43\x6f\x6c\
\x6f\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x20\x7b\x0a\
\x20\x20\x20\x20\x20\x20\x20\x63\x6f\x6c\x6f\x72\x3a\x23\x34\x64\
\x34\x64\x34\x64\x3b\x0a\x20\x20\x20\x20\x20\x7d\x0a\x20\x20\x20\
\x20\x20\x3c\x2f\x73\x74\x79\x6c\x65\x3e\x0a\x20\x3c\x2f\x64\x65\
\x66\x73\x3e\x0a\x20\x20\x20\x3c\x70\x61\x74\x68\x0a\x20\x20\x20\
\x20\x20\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x63\
\x75\x72\x72\x65\x6e\x74\x43\x6f\x6c\x6f\x72\x3b\x66\x69\x6c\x6c\
\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x31\x3b\x73\x74\x72\x6f\x6b\
\x65\x3a\x6e\x6f\x6e\x65\x22\x0a\x20\x20\x20\x20\x20\x20\x64\x3d\
\x22\x6d\x31\x30\x2e\x39\x39\x39\x39\x39\x39\x20\x33\x2e\x30\x30\
\x30\x30\x30\x32\x61\x38\x20\x38\x20\x30\x20\x30\x20\x30\x20\x2d\
\x38\x20\x38\x20\x38\x20\x38\x20\x30\x20\x30\x20\x30\x20\x38\x20\
\x38\x20\x38\x20\x38\x20\x30\x20\x30\x20\x30\x20\x38\x2d\x38\x20\
\x38\x20\x38\x20\x30\x20\x30\x20\x30\x20\x2d\x38\x2d\x38\x7a\x6d\
\x2d\x2e\x31\x39\x39\x32\x31\x39\x20\x33\x2e\x35\x61\x31\x20\x31\
\x20\x30\x20\x30\x20\x31\x20\x31\x20\x31\x20\x31\x20\x31\x20\x30\
\x20\x30\x20\x31\x20\x2d\x31\x20\x31\x20\x31\x20\x31\x20\x30\x20\
\x30\x20\x31\x20\x2d\x2e\x39\x39\x39\x39\x39\x39\x38\x2d\x31\x20\
\x31\x20\x31\x20\x30\x20\x30\x20\x31\x20\x20\x2e\x39\x39\x39\x39\
\x39\x39\x38\x2d\x31\x7a\x6d\x2d\x2e\x31\x30\x37\x34\x32\x32\x20\
\x33\x68\x20\x2e\x32\x31\x32\x38\x39\x31\x63\x2e\x33\x35\x36\x31\
\x34\x33\x20\x30\x20\x2e\x36\x34\x34\x35\x33\x31\x2e\x32\x38\x36\
\x34\x33\x35\x31\x2e\x36\x34\x34\x35\x33\x31\x2e\x36\x34\x32\x35\
\x37\x38\x76\x34\x2e\x37\x31\x34\x38\x34\x34\x63\x30\x20\x2e\x33\
\x35\x36\x31\x34\x33\x2d\x2e\x32\x38\x38\x33\x38\x38\x2e\x36\x34\
\x32\x35\x37\x38\x2d\x2e\x36\x34\x34\x35\x33\x31\x2e\x36\x34\x32\
\x35\x37\x38\x68\x2d\x2e\x32\x31\x32\x38\x39\x31\x63\x2d\x2e\x33\
\x35\x36\x31\x34\x33\x20\x30\x2d\x2e\x36\x34\x32\x35\x37\x38\x2d\
\x2e\x32\x38\x36\x34\x33\x35\x2d\x2e\x36\x34\x32\x35\x37\x38\x2d\
\x2e\x36\x34\x32\x35\x37\x38\x76\x2d\x34\x2e\x37\x31\x34\x38\x34\
\x34\x63\x30\x2d\x2e\x33\x35\x36\x31\x34\x32\x39\x2e\x32\x38\x36\
\x34\x33\x35\x2d\x2e\x36\x34\x32\x35\x37\x38\x2e\x36\x34\x32\x35\
\x37\x38\x2d\x2e\x36\x34\x32\x35\x37\x38\x7a\x22\x0a\x20\x20\x20\
\x20\x20\x20\x63\x6c\x61\x73\x73\x3d\x22\x43\x6f\x6c\x6f\x72\x53\
\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x22\x20\x2f\x3e\x0a\x3c\
\x2f\x73\x76\x67\x3e\x20\x0a\
\x00\x00\x02\xc0\
\x3c\
\x73\x76\x67\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\
\x30\x2f\x73\x76\x67\x22\x20\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\
\x30\x20\x30\x20\x32\x32\x20\x32\x32\x22\x3e\x0a\x20\x3c\x64\x65\
\x66\x73\x20\x69\x64\x3d\x22\x64\x65\x66\x73\x33\x30\x35\x31\x22\
\x3e\x0a\x20\x20\x20\x3c\x73\x74\x79\x6c\x65\x20\x74\x79\x70\x65\
\x3d\x22\x74\x65\x78\x74\x2f\x63\x73\x73\x22\x20\x69\x64\x3d\x22\
\x63\x75\x72\x72\x65\x6e\x74\x2d\x63\x6f\x6c\x6f\x72\x2d\x73\x63\
\x68\x65\x6d\x65\x22\x3e\x0a\x20\x20\x20\x20\x20\x2e\x43\x6f\x6c\
\x6f\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x20\x7b\x0a\
\x20\x20\x20\x20\x20\x20\x20\x63\x6f\x6c\x6f\x72\x3a\x23\x34\x64\
\x34\x64\x34\x64\x3b\x0a\x20\x20\x20\x20\x20\x7d\x0a\x20\x20\x20\
\x20\x20\x3c\x2f\x73\x74\x79\x6c\x65\x3e\x0a\x20\x3c\x2f\x64\x65\
\x66\x73\x3e\x0a\x20\x20\x20\x3c\x70\x61\x74\x68\x0a\x20\x20\x20\
\x20\x20\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x63\
\x75\x72\x72\x65\x6e\x74\x43\x6f\x6c\x6f\x72\x3b\x66\x69\x6c\x6c\
\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x31\x3b\x73\x74\x72\x6f\x6b\
\x65\x3a\x6e\x6f\x6e\x65\x22\x0a\x20\x20\x20\x20\x20\x20\x64\x3d\
\x22\x6d\x32\x2e\x35\x30\x30\x30\x30\x30\x31\x20\x31\x30\x33\x34\
\x2e\x33\x36\x32\x32\x63\x2d\x2e\x32\x37\x37\x20\x30\x2d\x2e\x35\
\x2e\x32\x32\x33\x2d\x2e\x35\x2e\x35\x76\x31\x2e\x39\x36\x30\x39\
\x20\x31\x2e\x30\x33\x39\x31\x20\x31\x30\x2e\x30\x33\x39\x31\x63\
\x30\x20\x2e\x32\x35\x35\x37\x2e\x32\x30\x35\x32\x34\x35\x36\x2e\
\x34\x36\x30\x39\x2e\x34\x36\x30\x39\x33\x37\x35\x2e\x34\x36\x30\
\x39\x68\x31\x37\x2e\x30\x37\x38\x31\x32\x34\x34\x63\x2e\x32\x35\
\x35\x36\x39\x32\x20\x30\x20\x2e\x34\x36\x30\x39\x33\x38\x2d\x2e\
\x32\x30\x35\x32\x2e\x34\x36\x30\x39\x33\x38\x2d\x2e\x34\x36\x30\
\x39\x76\x2d\x31\x31\x2e\x30\x37\x38\x32\x63\x30\x2d\x2e\x32\x35\
\x35\x37\x2d\x2e\x32\x30\x35\x32\x34\x36\x2d\x2e\x34\x36\x30\x39\
\x2d\x2e\x34\x36\x30\x39\x33\x38\x2d\x2e\x34\x36\x30\x39\x68\x2d\
\x38\x2e\x31\x38\x31\x31\x35\x39\x63\x2d\x2e\x35\x36\x39\x38\x36\
\x35\x2e\x30\x31\x37\x2d\x2e\x38\x34\x36\x32\x39\x35\x2d\x2e\x31\
\x33\x32\x31\x2d\x31\x2e\x30\x39\x37\x36\x32\x38\x2d\x2e\x33\x36\
\x38\x31\x6c\x2d\x31\x2e\x31\x38\x38\x34\x30\x31\x39\x2d\x31\x2e\
\x32\x31\x63\x2d\x2e\x31\x36\x38\x30\x35\x2d\x2e\x32\x32\x30\x32\
\x2d\x2e\x32\x39\x34\x38\x37\x33\x2d\x2e\x34\x32\x31\x39\x2d\x2e\
\x35\x37\x31\x38\x37\x33\x2d\x2e\x34\x32\x31\x39\x7a\x22\x0a\x20\
\x20\x20\x20\x20\x20\x63\x6c\x61\x73\x73\x3d\x22\x43\x6f\x6c\x6f\
\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x22\x20\x0a\x20\
\x20\x20\x20\x20\x20\x74\x72\x61\x6e\x73\x66\x6f\x72\x6d\x3d\x22\
\x6d\x61\x74\x72\x69\x78\x28\x2e\x38\x38\x38\x38\x38\x38\x38\x39\
\x20\x30\x20\x30\x20\x2e\x38\x38\x38\x38\x38\x38\x38\x39\x20\x31\
\x2e\x32\x32\x32\x32\x32\x32\x20\x2d\x39\x31\x34\x2e\x38\x37\x37\
\x35\x31\x29\x22\x2f\x3e\x0a\x3c\x2f\x73\x76\x67\x3e\x20\x0a\
\x00\x00\x03\xa0\
\x3c\
\x73\x76\x67\x20\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\x30\x20\x30\
\x20\x32\x32\x20\x32\x32\x22\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\
\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\
\x2f\x32\x30\x30\x30\x2f\x73\x76\x67\x22\x3e\x0a\x3c\x64\x65\x66\
\x73\x20\x69\x64\x3d\x22\x64\x65\x66\x73\x22\x3e\x0a\x20\x20\x20\
\x20\x3c\x73\x74\x79\x6c\x65\x20\x74\x79\x70\x65\x3d\x22\x74\x65\
\x78\x74\x2f\x63\x73\x73\x22\x20\x69\x64\x3d\x22\x63\x75\x72\x72\
\x65\x6e\x74\x2d\x63\x6f\x6c\x6f\x72\x2d\x73\x63\x68\x65\x6d\x65\
\x22\x3e\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x2e\x43\x6f\x6c\x6f\
\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x20\x7b\x20\x63\
\x6f\x6c\x6f\x72\x3a\x20\x23\x34\x64\x34\x64\x34\x64\x3b\x20\x7d\
\x0a\x20\x20\x20\x20\x3c\x2f\x73\x74\x79\x6c\x65\x3e\x0a\x3c\x2f\
\x64\x65\x66\x73\x3e\x0a\x3c\x70\x61\x74\x68\x20\x73\x74\x79\x6c\
\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x63\x75\x72\x72\x65\x6e\x74\x43\
\x6f\x6c\x6f\x72\x3b\x66\x69\x6c\x6c\x2d\x6f\x70\x61\x63\x69\x74\
\x79\x3b\x73\x74\x72\x6f\x6b\x65\x3a\x6e\x6f\x6e\x65\x22\x20\x63\
\x6c\x61\x73\x73\x3d\x22\x43\x6f\x6c\x6f\x72\x53\x63\x68\x65\x6d\
\x65\x2d\x54\x65\x78\x74\x22\x20\x64\x3d\x22\x6d\x33\x2e\x36\x36\
\x37\x39\x36\x38\x38\x20\x33\x63\x2d\x2e\x33\x36\x39\x31\x33\x33\
\x39\x20\x30\x2d\x2e\x36\x36\x37\x39\x36\x38\x38\x2e\x32\x39\x38\
\x38\x37\x34\x39\x2d\x2e\x36\x36\x37\x39\x36\x38\x38\x2e\x36\x36\
\x37\x39\x36\x38\x38\x76\x31\x34\x2e\x36\x36\x34\x30\x36\x32\x32\
\x63\x30\x20\x2e\x33\x36\x39\x31\x33\x34\x2e\x32\x39\x38\x38\x33\
\x34\x39\x2e\x36\x36\x37\x39\x36\x39\x2e\x36\x36\x37\x39\x36\x38\
\x38\x2e\x36\x36\x37\x39\x36\x39\x68\x31\x34\x2e\x36\x36\x34\x30\
\x36\x32\x32\x63\x2e\x33\x36\x39\x31\x33\x34\x20\x30\x20\x2e\x36\
\x36\x37\x39\x36\x39\x2d\x2e\x32\x39\x38\x38\x33\x35\x2e\x36\x36\
\x37\x39\x36\x39\x2d\x2e\x36\x36\x37\x39\x36\x39\x76\x2d\x31\x31\
\x2e\x35\x35\x38\x35\x39\x33\x35\x63\x30\x2d\x2e\x31\x37\x37\x32\
\x31\x33\x33\x2d\x2e\x30\x36\x39\x39\x33\x39\x2d\x2e\x33\x34\x37\
\x33\x31\x35\x37\x2d\x2e\x31\x39\x35\x33\x31\x32\x2d\x2e\x34\x37\
\x32\x36\x35\x36\x33\x6c\x2d\x33\x2e\x31\x30\x35\x34\x36\x39\x2d\
\x33\x2e\x31\x30\x35\x34\x36\x38\x37\x63\x2d\x2e\x31\x32\x35\x33\
\x34\x2d\x2e\x31\x32\x35\x33\x33\x33\x33\x2d\x2e\x32\x39\x35\x33\
\x35\x31\x2d\x2e\x31\x39\x35\x33\x31\x32\x35\x2d\x2e\x34\x37\x32\
\x36\x35\x37\x2d\x2e\x31\x39\x35\x33\x31\x32\x35\x7a\x6d\x31\x2e\
\x39\x37\x30\x37\x30\x33\x31\x20\x31\x2e\x35\x32\x37\x33\x34\x33\
\x38\x68\x39\x2e\x31\x37\x37\x37\x33\x34\x31\x76\x34\x2e\x39\x30\
\x30\x33\x39\x30\x36\x68\x2d\x39\x2e\x31\x37\x37\x37\x33\x34\x31\
\x7a\x6d\x35\x2e\x35\x37\x30\x33\x31\x32\x31\x2e\x34\x37\x32\x36\
\x35\x36\x32\x63\x2d\x2e\x31\x31\x35\x30\x37\x33\x20\x30\x2d\x2e\
\x32\x30\x38\x39\x38\x34\x2e\x31\x30\x37\x33\x39\x34\x34\x2d\x2e\
\x32\x30\x38\x39\x38\x34\x2e\x32\x34\x30\x32\x33\x34\x34\x76\x33\
\x2e\x35\x31\x39\x35\x33\x31\x32\x63\x30\x20\x2e\x31\x33\x32\x38\
\x38\x2e\x30\x39\x33\x39\x31\x31\x2e\x32\x34\x30\x32\x33\x34\x34\
\x2e\x32\x30\x38\x39\x38\x34\x2e\x32\x34\x30\x32\x33\x34\x34\x68\
\x31\x2e\x35\x38\x32\x30\x33\x32\x63\x2e\x31\x31\x35\x30\x37\x33\
\x20\x30\x20\x2e\x32\x30\x38\x39\x38\x34\x2d\x2e\x31\x30\x37\x33\
\x35\x34\x34\x2e\x32\x30\x38\x39\x38\x34\x2d\x2e\x32\x34\x30\x32\
\x33\x34\x34\x76\x2d\x33\x2e\x35\x31\x39\x35\x33\x31\x32\x63\x30\
\x2d\x2e\x31\x33\x32\x38\x34\x2d\x2e\x30\x39\x33\x39\x31\x31\x2d\
\x2e\x32\x34\x30\x32\x33\x34\x34\x2d\x2e\x32\x30\x38\x39\x38\x34\
\x2d\x2e\x32\x34\x30\x32\x33\x34\x34\x7a\x22\x20\x74\x72\x61\x6e\
\x73\x66\x6f\x72\x6d\x3d\x22\x6d\x61\x74\x72\x69\x78\x28\x31\x2e\
\x30\x30\x30\x30\x30\x30\x30\x30\x35\x20\x30\x20\x30\x20\x31\x2e\
\x30\x30\x30\x30\x30\x30\x30\x30\x35\x20\x2e\x30\x30\x30\x30\x30\
\x31\x32\x37\x35\x32\x33\x38\x20\x2e\x30\x30\x30\x30\x30\x31\x37\
\x32\x32\x36\x36\x29\x22\x2f\x3e\x3c\x2f\x73\x76\x67\x3e\x0a\
\x00\x00\x06\xf8\
\x3c\
\x73\x76\x67\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x32\x30\x30\
\x30\x2f\x73\x76\x67\x22\x20\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\
\x30\x20\x30\x20\x32\x32\x20\x32\x32\x22\x3e\x0a\x20\x3c\x64\x65\
\x66\x73\x20\x69\x64\x3d\x22\x64\x65\x66\x73\x33\x30\x35\x31\x22\
\x3e\x0a\x20\x20\x20\x3c\x73\x74\x79\x6c\x65\x20\x74\x79\x70\x65\
\x3d\x22\x74\x65\x78\x74\x2f\x63\x73\x73\x22\x20\x69\x64\x3d\x22\
\x63\x75\x72\x72\x65\x6e\x74\x2d\x63\x6f\x6c\x6f\x72\x2d\x73\x63\
\x68\x65\x6d\x65\x22\x3e\x0a\x20\x20\x20\x20\x20\x2e\x43\x6f\x6c\
\x6f\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x20\x7b\x0a\
\x20\x20\x20\x20\x20\x20\x20\x63\x6f\x6c\x6f\x72\x3a\x23\x34\x64\
\x34\x64\x34\x64\x3b\x0a\x20\x20\x20\x20\x20\x7d\x0a\x20\x20\x20\
\x20\x20\x3c\x2f\x73\x74\x79\x6c\x65\x3e\x0a\x20\x3c\x2f\x64\x65\
\x66\x73\x3e\x0a\x20\x20\x20\x3c\x70\x61\x74\x68\x0a\x20\x20\x20\
\x20\x20\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x63\
\x75\x72\x72\x65\x6e\x74\x43\x6f\x6c\x6f\x72\x3b\x66\x69\x6c\x6c\
\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x31\x3b\x73\x74\x72\x6f\x6b\
\x65\x3a\x6e\x6f\x6e\x65\x22\x0a\x20\x20\x20\x20\x20\x20\x64\x3d\
\x22\x6d\x31\x37\x2e\x39\x32\x37\x32\x39\x39\x20\x36\x2e\x39\x38\
\x34\x33\x34\x63\x2d\x2e\x37\x31\x35\x33\x34\x38\x2d\x31\x2e\x32\
\x32\x35\x36\x32\x2d\x31\x2e\x36\x38\x35\x37\x36\x35\x2d\x32\x2e\
\x31\x39\x36\x30\x34\x2d\x32\x2e\x39\x31\x31\x33\x38\x31\x2d\x32\
\x2e\x39\x31\x31\x33\x38\x2d\x31\x2e\x32\x32\x35\x38\x37\x31\x2d\
\x2e\x37\x31\x35\x33\x35\x2d\x32\x2e\x35\x36\x34\x31\x32\x37\x2d\
\x31\x2e\x30\x37\x32\x39\x36\x2d\x34\x2e\x30\x31\x35\x36\x36\x32\
\x2d\x31\x2e\x30\x37\x32\x39\x36\x2d\x31\x2e\x34\x35\x31\x34\x30\
\x37\x35\x20\x30\x2d\x32\x2e\x37\x39\x30\x30\x34\x36\x38\x2e\x33\
\x35\x37\x36\x31\x2d\x34\x2e\x30\x31\x35\x36\x36\x32\x35\x20\x31\
\x2e\x30\x37\x32\x39\x36\x2d\x31\x2e\x32\x32\x35\x37\x34\x33\x36\
\x2e\x37\x31\x35\x32\x32\x2d\x32\x2e\x31\x39\x36\x31\x36\x31\x32\
\x20\x31\x2e\x36\x38\x35\x36\x33\x2d\x32\x2e\x39\x31\x31\x35\x30\
\x38\x35\x20\x32\x2e\x39\x31\x31\x33\x38\x2d\x2e\x37\x31\x35\x34\
\x37\x35\x32\x20\x31\x2e\x32\x32\x35\x37\x34\x2d\x31\x2e\x30\x37\
\x33\x30\x38\x35\x20\x32\x2e\x35\x36\x34\x33\x38\x2d\x31\x2e\x30\
\x37\x33\x30\x38\x35\x20\x34\x2e\x30\x31\x35\x36\x36\x20\x30\x20\
\x31\x2e\x34\x35\x31\x34\x31\x2e\x33\x35\x37\x37\x33\x37\x36\x20\
\x32\x2e\x37\x38\x39\x37\x39\x20\x31\x2e\x30\x37\x32\x39\x35\x37\
\x31\x20\x34\x2e\x30\x31\x35\x36\x36\x2e\x37\x31\x35\x33\x34\x37\
\x34\x20\x31\x2e\x32\x32\x35\x34\x39\x20\x31\x2e\x36\x38\x35\x37\
\x36\x35\x20\x32\x2e\x31\x39\x36\x30\x34\x20\x32\x2e\x39\x31\x31\
\x35\x30\x38\x35\x20\x32\x2e\x39\x31\x31\x33\x38\x20\x31\x2e\x32\
\x32\x35\x37\x34\x33\x36\x2e\x37\x31\x35\x33\x35\x20\x32\x2e\x35\
\x36\x34\x32\x35\x35\x31\x20\x31\x2e\x30\x37\x32\x39\x36\x20\x34\
\x2e\x30\x31\x35\x36\x36\x32\x34\x20\x31\x2e\x30\x37\x32\x39\x36\
\x20\x31\x2e\x34\x35\x31\x34\x30\x37\x20\x30\x20\x32\x2e\x37\x39\
\x30\x30\x34\x36\x2d\x2e\x33\x35\x37\x36\x31\x20\x34\x2e\x30\x31\
\x35\x36\x36\x32\x2d\x31\x2e\x30\x37\x32\x39\x36\x20\x31\x2e\x32\
\x32\x35\x36\x31\x36\x2d\x2e\x37\x31\x35\x32\x32\x20\x32\x2e\x31\
\x39\x36\x30\x33\x33\x2d\x31\x2e\x36\x38\x35\x37\x36\x20\x32\x2e\
\x39\x31\x31\x33\x38\x31\x2d\x32\x2e\x39\x31\x31\x33\x38\x2e\x37\
\x31\x35\x32\x31\x39\x2d\x31\x2e\x32\x32\x35\x37\x34\x20\x31\x2e\
\x30\x37\x32\x38\x32\x39\x2d\x32\x2e\x35\x36\x34\x33\x38\x20\x31\
\x2e\x30\x37\x32\x38\x32\x39\x2d\x34\x2e\x30\x31\x35\x36\x36\x20\
\x30\x2d\x31\x2e\x34\x35\x31\x34\x31\x2d\x2e\x33\x35\x37\x36\x31\
\x2d\x32\x2e\x37\x39\x30\x30\x35\x2d\x31\x2e\x30\x37\x32\x37\x30\
\x31\x2d\x34\x2e\x30\x31\x35\x36\x36\x7a\x6d\x2d\x33\x2e\x31\x35\
\x36\x33\x35\x31\x20\x35\x2e\x39\x30\x31\x30\x31\x63\x2e\x31\x33\
\x31\x39\x34\x36\x2e\x31\x33\x31\x38\x31\x2e\x31\x39\x38\x30\x34\
\x37\x2e\x32\x38\x38\x33\x31\x2e\x31\x39\x38\x30\x34\x37\x2e\x34\
\x36\x38\x38\x34\x20\x30\x20\x2e\x31\x38\x37\x34\x33\x2d\x2e\x30\
\x36\x36\x31\x2e\x33\x34\x37\x32\x35\x2d\x2e\x31\x39\x38\x30\x34\
\x37\x2e\x34\x37\x39\x30\x37\x6c\x2d\x2e\x39\x33\x37\x34\x33\x31\
\x2e\x39\x33\x37\x35\x36\x63\x2d\x2e\x31\x33\x31\x39\x34\x36\x2e\
\x31\x33\x31\x39\x35\x2d\x2e\x32\x39\x31\x36\x33\x37\x2e\x31\x39\
\x37\x39\x32\x2d\x2e\x34\x37\x39\x32\x2e\x31\x39\x37\x39\x32\x2d\
\x2e\x31\x38\x30\x35\x33\x20\x30\x2d\x2e\x33\x33\x37\x30\x32\x35\
\x2d\x2e\x30\x36\x36\x2d\x2e\x34\x36\x38\x37\x31\x35\x2d\x2e\x31\
\x39\x37\x39\x32\x6c\x2d\x31\x2e\x38\x38\x35\x34\x37\x34\x2d\x31\
\x2e\x38\x38\x35\x34\x37\x2d\x31\x2e\x38\x38\x35\x34\x37\x34\x32\
\x20\x31\x2e\x38\x38\x35\x34\x37\x63\x2d\x2e\x31\x33\x31\x39\x34\
\x36\x32\x2e\x31\x33\x31\x39\x35\x2d\x2e\x32\x38\x38\x31\x38\x34\
\x37\x2e\x31\x39\x37\x39\x32\x2d\x2e\x34\x36\x38\x37\x31\x35\x36\
\x2e\x31\x39\x37\x39\x32\x2d\x2e\x31\x38\x37\x35\x36\x32\x39\x20\
\x30\x2d\x2e\x33\x34\x37\x32\x35\x33\x35\x2d\x2e\x30\x36\x36\x2d\
\x2e\x34\x37\x39\x31\x39\x39\x36\x2d\x2e\x31\x39\x37\x39\x32\x6c\
\x2d\x2e\x39\x33\x37\x35\x35\x38\x39\x2d\x2e\x39\x33\x37\x35\x36\
\x63\x2d\x2e\x31\x33\x31\x39\x34\x36\x32\x2d\x2e\x31\x33\x31\x38\
\x32\x2d\x2e\x31\x39\x37\x39\x31\x39\x32\x2d\x2e\x32\x39\x31\x36\
\x34\x2d\x2e\x31\x39\x37\x39\x31\x39\x32\x2d\x2e\x34\x37\x39\x30\
\x37\x20\x30\x2d\x2e\x31\x38\x30\x35\x33\x2e\x30\x36\x35\x39\x37\
\x33\x2d\x2e\x33\x33\x37\x30\x33\x2e\x31\x39\x37\x39\x31\x39\x32\
\x2d\x2e\x34\x36\x38\x38\x34\x6c\x31\x2e\x38\x38\x35\x34\x37\x34\
\x31\x2d\x31\x2e\x38\x38\x35\x33\x35\x2d\x31\x2e\x38\x38\x35\x34\
\x37\x34\x31\x2d\x31\x2e\x38\x38\x35\x34\x37\x63\x2d\x2e\x31\x33\
\x31\x39\x34\x36\x32\x2d\x2e\x31\x33\x31\x38\x32\x2d\x2e\x31\x39\
\x37\x39\x31\x39\x32\x2d\x2e\x32\x38\x38\x31\x39\x2d\x2e\x31\x39\
\x37\x39\x31\x39\x32\x2d\x2e\x34\x36\x38\x37\x32\x20\x30\x2d\x2e\
\x31\x38\x37\x35\x36\x2e\x30\x36\x35\x39\x37\x33\x2d\x2e\x33\x34\
\x37\x32\x35\x2e\x31\x39\x37\x39\x31\x39\x32\x2d\x2e\x34\x37\x39\
\x32\x6c\x2e\x39\x33\x37\x35\x35\x38\x39\x2d\x2e\x39\x33\x37\x34\
\x33\x63\x2e\x31\x33\x31\x39\x34\x36\x31\x2d\x2e\x31\x33\x31\x39\
\x35\x2e\x32\x39\x31\x36\x33\x36\x37\x2d\x2e\x31\x39\x37\x39\x32\
\x2e\x34\x37\x39\x31\x39\x39\x36\x2d\x2e\x31\x39\x37\x39\x32\x2e\
\x31\x38\x30\x35\x33\x30\x39\x20\x30\x20\x2e\x33\x33\x36\x37\x36\
\x39\x34\x2e\x30\x36\x36\x2e\x34\x36\x38\x37\x31\x35\x36\x2e\x31\
\x39\x37\x39\x32\x6c\x31\x2e\x38\x38\x35\x34\x37\x34\x32\x20\x31\
\x2e\x38\x38\x35\x33\x35\x20\x31\x2e\x38\x38\x35\x34\x37\x34\x2d\
\x31\x2e\x38\x38\x35\x33\x35\x63\x2e\x31\x33\x31\x36\x39\x2d\x2e\
\x31\x33\x31\x39\x35\x2e\x32\x38\x38\x31\x38\x35\x2d\x2e\x31\x39\
\x37\x39\x32\x2e\x34\x36\x38\x37\x31\x35\x2d\x2e\x31\x39\x37\x39\
\x32\x2e\x31\x38\x37\x35\x36\x33\x20\x30\x20\x2e\x33\x34\x37\x32\
\x35\x34\x2e\x30\x36\x36\x2e\x34\x37\x39\x32\x2e\x31\x39\x37\x39\
\x32\x6c\x2e\x39\x33\x37\x34\x33\x31\x2e\x39\x33\x37\x34\x33\x63\
\x2e\x31\x33\x31\x39\x34\x36\x2e\x31\x33\x31\x39\x35\x2e\x31\x39\
\x38\x30\x34\x37\x2e\x32\x39\x31\x36\x34\x2e\x31\x39\x38\x30\x34\
\x37\x2e\x34\x37\x39\x32\x20\x30\x20\x2e\x31\x38\x30\x35\x33\x2d\
\x2e\x30\x36\x36\x31\x2e\x33\x33\x36\x39\x2d\x2e\x31\x39\x38\x30\
\x34\x37\x2e\x34\x36\x38\x37\x32\x6c\x2d\x31\x2e\x38\x38\x35\x33\
\x34\x36\x20\x31\x2e\x38\x38\x35\x34\x37\x7a\x22\x0a\x20\x20\x20\
\x20\x20\x20\x63\x6c\x61\x73\x73\x3d\x22\x43\x6f\x6c\x6f\x72\x53\
\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x22\x20\x2f\x3e\x0a\x3c\
\x2f\x73\x76\x67\x3e\x20\x0a\
\x00\x00\x03\x18\
\x20\
\x20\x20\x20\x3c\x73\x76\x67\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\
\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\
\x2f\x32\x30\x30\x30\x2f\x73\x76\x67\x22\x20\x76\x69\x65\x77\x42\
\x6f\x78\x3d\x22\x30\x20\x30\x20\x32\x32\x20\x32\x32\x22\x3e\x0a\
\x20\x3c\x64\x65\x66\x73\x20\x69\x64\x3d\x22\x64\x65\x66\x73\x33\
\x30\x35\x31\x22\x3e\x0a\x20\x20\x20\x3c\x73\x74\x79\x6c\x65\x20\
\x74\x79\x70\x65\x3d\x22\x74\x65\x78\x74\x2f\x63\x73\x73\x22\x20\
\x69\x64\x3d\x22\x63\x75\x72\x72\x65\x6e\x74\x2d\x63\x6f\x6c\x6f\
\x72\x2d\x73\x63\x68\x65\x6d\x65\x22\x3e\x0a\x20\x20\x20\x20\x20\
\x2e\x43\x6f\x6c\x6f\x72\x53\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\
\x74\x20\x7b\x0a\x20\x20\x20\x20\x20\x20\x20\x63\x6f\x6c\x6f\x72\
\x3a\x23\x34\x64\x34\x64\x34\x64\x3b\x0a\x20\x20\x20\x20\x20\x7d\
\x0a\x20\x20\x20\x20\x20\x3c\x2f\x73\x74\x79\x6c\x65\x3e\x0a\x20\
\x3c\x2f\x64\x65\x66\x73\x3e\x0a\x20\x20\x20\x3c\x70\x61\x74\x68\
\x0a\x20\x20\x20\x20\x20\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\
\x6c\x6c\x3a\x63\x75\x72\x72\x65\x6e\x74\x43\x6f\x6c\x6f\x72\x3b\
\x66\x69\x6c\x6c\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x31\x3b\x73\
\x74\x72\x6f\x6b\x65\x3a\x6e\x6f\x6e\x65\x22\x0a\x20\x20\x20\x20\
\x20\x20\x64\x3d\x22\x6d\x39\x2e\x36\x36\x36\x36\x36\x37\x20\x33\
\x63\x2d\x2e\x32\x34\x36\x32\x34\x39\x20\x30\x2d\x2e\x34\x34\x34\
\x34\x34\x35\x2e\x31\x39\x38\x31\x39\x35\x36\x2d\x2e\x34\x34\x34\
\x34\x34\x35\x2e\x34\x34\x34\x34\x34\x34\x34\x76\x35\x2e\x37\x37\
\x37\x37\x37\x37\x36\x68\x2d\x35\x2e\x37\x37\x37\x37\x37\x37\x36\
\x63\x2d\x2e\x32\x34\x36\x32\x32\x32\x32\x20\x30\x2d\x2e\x34\x34\
\x34\x34\x34\x34\x34\x2e\x31\x39\x38\x32\x32\x32\x2d\x2e\x34\x34\
\x34\x34\x34\x34\x34\x2e\x34\x34\x34\x34\x34\x35\x76\x32\x2e\x36\
\x36\x36\x36\x36\x36\x63\x30\x20\x2e\x32\x34\x36\x32\x32\x33\x2e\
\x31\x39\x38\x32\x32\x32\x32\x2e\x34\x34\x34\x34\x34\x35\x2e\x34\
\x34\x34\x34\x34\x34\x34\x2e\x34\x34\x34\x34\x34\x35\x68\x35\x2e\
\x37\x37\x37\x37\x37\x37\x36\x76\x35\x2e\x37\x37\x37\x37\x37\x38\
\x63\x30\x20\x2e\x32\x34\x36\x32\x34\x38\x2e\x31\x39\x38\x31\x39\
\x36\x2e\x34\x34\x34\x34\x34\x34\x2e\x34\x34\x34\x34\x34\x35\x2e\
\x34\x34\x34\x34\x34\x34\x68\x32\x2e\x36\x36\x36\x36\x36\x36\x63\
\x2e\x32\x34\x36\x32\x34\x39\x20\x30\x20\x2e\x34\x34\x34\x34\x34\
\x35\x2d\x2e\x31\x39\x38\x31\x39\x36\x2e\x34\x34\x34\x34\x34\x35\
\x2d\x2e\x34\x34\x34\x34\x34\x34\x76\x2d\x35\x2e\x37\x37\x37\x37\
\x37\x38\x68\x35\x2e\x37\x37\x37\x37\x37\x38\x63\x2e\x32\x34\x36\
\x32\x32\x32\x20\x30\x20\x2e\x34\x34\x34\x34\x34\x34\x2d\x2e\x31\
\x39\x38\x32\x32\x32\x2e\x34\x34\x34\x34\x34\x34\x2d\x2e\x34\x34\
\x34\x34\x34\x35\x76\x2d\x32\x2e\x36\x36\x36\x36\x36\x36\x63\x30\
\x2d\x2e\x32\x34\x36\x32\x32\x33\x2d\x2e\x31\x39\x38\x32\x32\x32\
\x2d\x2e\x34\x34\x34\x34\x34\x35\x2d\x2e\x34\x34\x34\x34\x34\x34\
\x2d\x2e\x34\x34\x34\x34\x34\x35\x68\x2d\x35\x2e\x37\x37\x37\x37\
\x37\x38\x76\x2d\x35\x2e\x37\x37\x37\x37\x37\x37\x36\x63\x30\x2d\
\x2e\x32\x34\x36\x32\x34\x38\x38\x2d\x2e\x31\x39\x38\x31\x39\x36\
\x2d\x2e\x34\x34\x34\x34\x34\x34\x34\x2d\x2e\x34\x34\x34\x34\x34\
\x35\x2d\x2e\x34\x34\x34\x34\x34\x34\x34\x7a\x22\x0a\x20\x20\x20\
\x20\x20\x20\x63\x6c\x61\x73\x73\x3d\x22\x43\x6f\x6c\x6f\x72\x53\
\x63\x68\x65\x6d\x65\x2d\x54\x65\x78\x74\x22\x20\x2f\x3e\x0a\x3c\
\x2f\x73\x76\x67\x3e\x20\x0a\
"
qt_resource_name = b"\
\x00\x0d\
\x01\x1c\xbc\x27\
\x00\x65\
\x00\x64\x00\x69\x00\x74\x00\x2d\x00\x63\x00\x6f\x00\x70\x00\x79\x00\x2e\x00\x73\x00\x76\x00\x67\
\x00\x0e\
\x0c\xaa\xcd\x27\
\x00\x65\
\x00\x64\x00\x69\x00\x74\x00\x2d\x00\x70\x00\x61\x00\x73\x00\x74\x00\x65\x00\x2e\x00\x73\x00\x76\x00\x67\
\x00\x0c\
\x07\xb1\x54\xa7\
\x00\x65\
\x00\x64\x00\x69\x00\x74\x00\x2d\x00\x63\x00\x75\x00\x74\x00\x2e\x00\x73\x00\x76\x00\x67\
\x00\x10\
\x0e\x38\x21\x47\
\x00\x68\
\x00\x65\x00\x6c\x00\x70\x00\x2d\x00\x63\x00\x6f\x00\x6e\x00\x74\x00\x65\x00\x6e\x00\x74\x00\x2e\x00\x73\x00\x76\x00\x67\
\x00\x0d\
\x0c\xc4\x53\xa7\
\x00\x66\
\x00\x69\x00\x6c\x00\x65\x00\x2d\x00\x6f\x00\x70\x00\x65\x00\x6e\x00\x2e\x00\x73\x00\x76\x00\x67\
\x00\x0d\
\x02\xc5\x52\x47\
\x00\x66\
\x00\x69\x00\x6c\x00\x65\x00\x2d\x00\x73\x00\x61\x00\x76\x00\x65\x00\x2e\x00\x73\x00\x76\x00\x67\
\x00\x0d\
\x05\x02\x5c\xe7\
\x00\x66\
\x00\x69\x00\x6c\x00\x65\x00\x2d\x00\x65\x00\x78\x00\x69\x00\x74\x00\x2e\x00\x73\x00\x76\x00\x67\
\x00\x0c\
\x09\x6a\x0a\x47\
\x00\x66\
\x00\x69\x00\x6c\x00\x65\x00\x2d\x00\x6e\x00\x65\x00\x77\x00\x2e\x00\x73\x00\x76\x00\x67\
"
qt_resource_struct_v1 = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x08\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x00\xa6\x00\x00\x00\x00\x00\x01\x00\x00\x13\x0e\
\x00\x00\x00\xc6\x00\x00\x00\x00\x00\x01\x00\x00\x16\xb2\
\x00\x00\x00\x42\x00\x00\x00\x00\x00\x01\x00\x00\x06\xb4\
\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x01\x00\x00\x1d\xae\
\x00\x00\x00\x20\x00\x00\x00\x00\x00\x01\x00\x00\x03\xb5\
\x00\x00\x00\x86\x00\x00\x00\x00\x00\x01\x00\x00\x10\x4a\
\x00\x00\x00\x60\x00\x00\x00\x00\x00\x01\x00\x00\x0d\x7e\
"
qt_resource_struct_v2 = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x08\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x71\x23\x58\xcf\x38\
\x00\x00\x00\xa6\x00\x00\x00\x00\x00\x01\x00\x00\x13\x0e\
\x00\x00\x01\x71\x23\x58\xcf\x38\
\x00\x00\x00\xc6\x00\x00\x00\x00\x00\x01\x00\x00\x16\xb2\
\x00\x00\x01\x71\x23\x58\xcf\x38\
\x00\x00\x00\x42\x00\x00\x00\x00\x00\x01\x00\x00\x06\xb4\
\x00\x00\x01\x71\x23\x58\xcf\x38\
\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x01\x00\x00\x1d\xae\
\x00\x00\x01\x71\x23\x58\xcf\x38\
\x00\x00\x00\x20\x00\x00\x00\x00\x00\x01\x00\x00\x03\xb5\
\x00\x00\x01\x71\x23\x58\xcf\x38\
\x00\x00\x00\x86\x00\x00\x00\x00\x00\x01\x00\x00\x10\x4a\
\x00\x00\x01\x71\x23\x58\xcf\x38\
\x00\x00\x00\x60\x00\x00\x00\x00\x00\x01\x00\x00\x0d\x7e\
\x00\x00\x01\x71\x23\x58\xcf\x38\
"
qt_version = QtCore.qVersion().split(".")
if qt_version < ["5", "8", "0"]:
rcc_version = 1
qt_resource_struct = qt_resource_struct_v1
else:
rcc_version = 2
qt_resource_struct = qt_resource_struct_v2
def qInitResources():
QtCore.qRegisterResourceData(
rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data
)
def qCleanupResources():
QtCore.qUnregisterResourceData(
rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data
)
qInitResources()
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file alias="file-new.svg">resources/file-new.svg</file>
<file alias="file-open.svg">resources/file-open.svg</file>
<file alias="file-save.svg">resources/file-save.svg</file>
<file alias="file-exit.svg">resources/file-exit.svg</file>
<file alias="edit-copy.svg">resources/edit-copy.svg</file>
<file alias="edit-cut.svg">resources/edit-cut.svg</file>
<file alias="edit-paste.svg">resources/edit-paste.svg</file>
<file alias="help-content.svg">resources/help-content.svg</file>
</qresource>
</RCC>
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="m14.999993 6.0000017h-10.999988c-.5520048 0-1.000005.4480002-1.000005.9999916v11.0000017c0 .552005.4480002 1.000005 1.000005 1.000005h10.999988c.552005 0 1.000005-.448 1.000005-1.000005v-11.0000017c0-.5519914-.448-.9999916-1.000005-.9999916zm3.000002-3.0000017h-9.9999967c-.5520048 0-1.000005.4480002-1.000005 1.000005v.9999916h1.000005v-.5000025c0-.2759957.2240068-.4999891.5000025-.4999891h8.9999912c.27601 0 .500003.2239934.500003.4999891v9.0000049c0 .275996-.223993.500003-.500003.500003h-.499989v.999991h.999992c.552005 0 1.000005-.448 1.000005-.999991v-9.999997c0-.5520048-.448-1.000005-1.000005-1.000005z"
class="ColorScheme-Text" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="m7.0136719 2-.4355469.7753906c-.2699231.4812667-.5038694.7087891-.6289062 1.1367188-.0625185.2139647-.0612584.4699226.0019531.7011718.0632171.2312494.1726285.4527981.3261719.7265626l3.3945312 6.0625002-1.7148438 3.023437c-.4483616-.277461-.8911737-.591797-1.4550781-.591797-1.6582865 0-3.0019531 1.388975-3.0019531 3.083985 0 1.695008 1.3436663 3.082031 3.0019531 3.082031 1.658287 0 3.0019532-1.387023 3.0019531-3.082031 0-.133955-.0209824-.259363-.0371093-.386719.4622484-1.003569.8985411-1.788627 1.8085941-2.248047.003037-.003375.002934-.004437.005859-.007812l1.253906 2.238281c-.017223.134034-.039062.265801-.039062.404297 0 1.695008 1.343665 3.082031 3.001953 3.082031 1.658287 0 3.001953-1.387023 3.001953-3.082031 0-1.69501-1.343667-3.083985-3.001953-3.083985-.56176 0-1.004412.308543-1.451172.583985l-1.708984-3.015625 3.398437-6.0625002v-.0019532c.152934-.2728193.261159-.4939397.324219-.7246094.063214-.2312492.066332-.4872071.003906-.7011718-.125138-.4278882-.358984-.6554521-.628906-1.1367188l-.435547-.7753906-3.994141 7.0488281zm-.5117188 13.884766c.5564078 0 .9960938.448401.9960938 1.033203s-.439686 1.03125-.9960938 1.03125-.9941406-.446448-.9941406-1.03125c0-.584803.4377328-1.033203.9941406-1.033203zm8.9960939 0c .556407 0 .99414.448401.994141 1.033203 0 .584802-.437734 1.03125-.994141 1.03125-.556409 0-.996094-.446448-.996094-1.03125 0-.584803.439685-1.033203.996094-1.033203z"
class="ColorScheme-Text" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="m14.12662 8.00521h-.9452v-2.22935c0-.23294-.18815-.4217-.42014-.4217h-.45273l-.90589-3.0529c-.053-.17871-.21679-.30126-.40266-.30126-.18578 0-.34963.12255-.40266.30126l-.90589 3.0529h-.45273c-.23199 0-.42014.18876-.42014.4217v2.22942h-.9452c-1.03295 0-1.87338.84348-1.87338 1.88035v8.23403c0 1.03686.84035 1.88034 1.87338 1.88034h6.25324c1.03295 0 1.87338-.84348 1.87338-1.88034v-8.23403c0-1.03696-.84035-1.88042-1.87338-1.88042z"
class="ColorScheme-Text" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="m17.927299 6.98434c-.715348-1.22562-1.685765-2.19604-2.911381-2.91138-1.225871-.71535-2.564127-1.07296-4.015662-1.07296-1.4514075 0-2.7900468.35761-4.0156625 1.07296-1.2257436.71522-2.1961612 1.68563-2.9115085 2.91138-.7154752 1.22574-1.073085 2.56438-1.073085 4.01566 0 1.45141.3577376 2.78979 1.0729571 4.01566.7153474 1.22549 1.685765 2.19604 2.9115085 2.91138 1.2257436.71535 2.5642551 1.07296 4.0156624 1.07296 1.451407 0 2.790046-.35761 4.015662-1.07296 1.225616-.71522 2.196033-1.68576 2.911381-2.91138.715219-1.22574 1.072829-2.56438 1.072829-4.01566 0-1.45141-.35761-2.79005-1.072701-4.01566zm-3.156351 5.90101c.131946.13181.198047.28831.198047.46884 0 .18743-.0661.34725-.198047.47907l-.937431.93756c-.131946.13195-.291637.19792-.4792.19792-.18053 0-.337025-.066-.468715-.19792l-1.885474-1.88547-1.8854742 1.88547c-.1319462.13195-.2881847.19792-.4687156.19792-.1875629 0-.3472535-.066-.4791996-.19792l-.9375589-.93756c-.1319462-.13182-.1979192-.29164-.1979192-.47907 0-.18053.065973-.33703.1979192-.46884l1.8854741-1.88535-1.8854741-1.88547c-.1319462-.13182-.1979192-.28819-.1979192-.46872 0-.18756.065973-.34725.1979192-.4792l.9375589-.93743c.1319461-.13195.2916367-.19792.4791996-.19792.1805309 0 .3367694.066.4687156.19792l1.8854742 1.88535 1.885474-1.88535c.13169-.13195.288185-.19792.468715-.19792.187563 0 .347254.066.4792.19792l.937431.93743c.131946.13195.198047.29164.198047.4792 0 .18053-.0661.3369-.198047.46872l-1.885346 1.88547z"
class="ColorScheme-Text" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="m9.666667 3c-.246249 0-.444445.1981956-.444445.4444444v5.7777776h-5.7777776c-.2462222 0-.4444444.198222-.4444444.444445v2.666666c0 .246223.1982222.444445.4444444.444445h5.7777776v5.777778c0 .246248.198196.444444.444445.444444h2.666666c.246249 0 .444445-.198196.444445-.444444v-5.777778h5.777778c.246222 0 .444444-.198222.444444-.444445v-2.666666c0-.246223-.198222-.444445-.444444-.444445h-5.777778v-5.7777776c0-.2462488-.198196-.4444444-.444445-.4444444z"
class="ColorScheme-Text" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="m2.5000001 1034.3622c-.277 0-.5.223-.5.5v1.9609 1.0391 10.0391c0 .2557.2052456.4609.4609375.4609h17.0781244c.255692 0 .460938-.2052.460938-.4609v-11.0782c0-.2557-.205246-.4609-.460938-.4609h-8.181159c-.569865.017-.846295-.1321-1.097628-.3681l-1.1884019-1.21c-.16805-.2202-.294873-.4219-.571873-.4219z"
class="ColorScheme-Text"
transform="matrix(.88888889 0 0 .88888889 1.222222 -914.87751)"/>
</svg>
<svg viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg">
<defs id="defs">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text { color: #4d4d4d; }
</style>
</defs>
<path style="fill:currentColor;fill-opacity;stroke:none" class="ColorScheme-Text" d="m3.6679688 3c-.3691339 0-.6679688.2988749-.6679688.6679688v14.6640622c0 .369134.2988349.667969.6679688.667969h14.6640622c.369134 0 .667969-.298835.667969-.667969v-11.5585935c0-.1772133-.069939-.3473157-.195312-.4726563l-3.105469-3.1054687c-.12534-.1253333-.295351-.1953125-.472657-.1953125zm1.9707031 1.5273438h9.1777341v4.9003906h-9.1777341zm5.5703121.4726562c-.115073 0-.208984.1073944-.208984.2402344v3.5195312c0 .13288.093911.2402344.208984.2402344h1.582032c.115073 0 .208984-.1073544.208984-.2402344v-3.5195312c0-.13284-.093911-.2402344-.208984-.2402344z" transform="matrix(1.000000005 0 0 1.000000005 .000001275238 .00000172266)"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="m10.999999 3.000002a8 8 0 0 0 -8 8 8 8 0 0 0 8 8 8 8 0 0 0 8-8 8 8 0 0 0 -8-8zm-.199219 3.5a1 1 0 0 1 1 1 1 1 0 0 1 -1 1 1 1 0 0 1 -.9999998-1 1 1 0 0 1 .9999998-1zm-.107422 3h .212891c.356143 0 .644531.2864351.644531.642578v4.714844c0 .356143-.288388.642578-.644531.642578h-.212891c-.356143 0-.642578-.286435-.642578-.642578v-4.714844c0-.3561429.286435-.642578.642578-.642578z"
class="ColorScheme-Text" />
</svg>
# 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.
"""Sample PyQt application."""
import sys
from functools import partial
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon, QKeySequence
from PyQt5.QtWidgets import (
QAction,
QApplication,
QLabel,
QMainWindow,
QMenu,
QSpinBox,
QToolBar,
)
# NOTE: Uncomment this import to enable icons
# import qrc_resources
class Window(QMainWindow):
"""Main Window."""
def __init__(self, parent=None):
"""Initializer."""
super().__init__(parent)
self.setWindowTitle("Python Menus & Toolbars")
self.resize(400, 200)
self.centralWidget = QLabel("Hello, World")
self.centralWidget.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
self.setCentralWidget(self.centralWidget)
self._createActions()
self._createMenuBar()
self._createToolBars()
# Uncomment the call to ._createContextMenu() below to create a context
# menu using menu policies. To test this out, you also need to
# comment .contextMenuEvent() and uncomment ._createContextMenu()
# self._createContextMenu()
self._connectActions()
self._createStatusBar()
def _createMenuBar(self):
menuBar = self.menuBar()
# File menu
fileMenu = QMenu("&File", self)
menuBar.addMenu(fileMenu)
fileMenu.addAction(self.newAction)
fileMenu.addAction(self.openAction)
# Open Recent submenu
self.openRecentMenu = fileMenu.addMenu("Open Recent")
fileMenu.addAction(self.saveAction)
# Separator
fileMenu.addSeparator()
fileMenu.addAction(self.exitAction)
# Edit menu
editMenu = menuBar.addMenu("&Edit")
editMenu.addAction(self.copyAction)
editMenu.addAction(self.pasteAction)
editMenu.addAction(self.cutAction)
# Separator
editMenu.addSeparator()
# Find and Replace submenu
findMenu = editMenu.addMenu("Find and Replace")
findMenu.addAction("Find...")
findMenu.addAction("Replace...")
# Help menu
helpMenu = menuBar.addMenu(QIcon(":help-content.svg"), "&Help")
helpMenu.addAction(self.helpContentAction)
helpMenu.addAction(self.aboutAction)
def _createToolBars(self):
# File toolbar
fileToolBar = self.addToolBar("File")
fileToolBar.setMovable(False)
fileToolBar.addAction(self.newAction)
fileToolBar.addAction(self.openAction)
fileToolBar.addAction(self.saveAction)
# Edit toolbar
editToolBar = QToolBar("Edit", self)
self.addToolBar(editToolBar)
editToolBar.addAction(self.copyAction)
editToolBar.addAction(self.pasteAction)
editToolBar.addAction(self.cutAction)
# Widgets
self.fontSizeSpinBox = QSpinBox()
self.fontSizeSpinBox.setFocusPolicy(Qt.NoFocus)
editToolBar.addWidget(self.fontSizeSpinBox)
def _createStatusBar(self):
self.statusbar = self.statusBar()
# Temporary message
self.statusbar.showMessage("Ready", 3000)
# Permanent widget
self.wcLabel = QLabel(f"{self.getWordCount()} Words")
self.statusbar.addPermanentWidget(self.wcLabel)
def _createActions(self):
# File actions
self.newAction = QAction(self)
self.newAction.setText("&New")
self.newAction.setIcon(QIcon(":file-new.svg"))
self.openAction = QAction(QIcon(":file-open.svg"), "&Open...", self)
self.saveAction = QAction(QIcon(":file-save.svg"), "&Save", self)
self.exitAction = QAction("&Exit", self)
# String-based key sequences
self.newAction.setShortcut("Ctrl+N")
self.openAction.setShortcut("Ctrl+O")
self.saveAction.setShortcut("Ctrl+S")
# Help tips
newTip = "Create a new file"
self.newAction.setStatusTip(newTip)
self.newAction.setToolTip(newTip)
self.newAction.setWhatsThis("Create a new and empty text file")
# Edit actions
self.copyAction = QAction(QIcon(":edit-copy.svg"), "&Copy", self)
self.pasteAction = QAction(QIcon(":edit-paste.svg"), "&Paste", self)
self.cutAction = QAction(QIcon(":edit-cut.svg"), "C&ut", self)
# Standard key sequence
self.copyAction.setShortcut(QKeySequence.Copy)
self.pasteAction.setShortcut(QKeySequence.Paste)
self.cutAction.setShortcut(QKeySequence.Cut)
# Help actions
self.helpContentAction = QAction("&Help Content...", self)
self.aboutAction = QAction("&About...", self)
# Uncomment this method to create a context menu using menu policies
# def _createContextMenu(self):
# # Setting contextMenuPolicy
# self.centralWidget.setContextMenuPolicy(Qt.ActionsContextMenu)
# # Populating the widget with actions
# self.centralWidget.addAction(self.newAction)
# self.centralWidget.addAction(self.openAction)
# self.centralWidget.addAction(self.saveAction)
# self.centralWidget.addAction(self.copyAction)
# self.centralWidget.addAction(self.pasteAction)
# self.centralWidget.addAction(self.cutAction)
def contextMenuEvent(self, event):
# Context menu
menu = QMenu(self.centralWidget)
# Populating the menu with actions
menu.addAction(self.newAction)
menu.addAction(self.openAction)
menu.addAction(self.saveAction)
# Separator
separator = QAction(self)
separator.setSeparator(True)
menu.addAction(separator)
menu.addAction(self.copyAction)
menu.addAction(self.pasteAction)
menu.addAction(self.cutAction)
# Launching the menu
menu.exec(event.globalPos())
def _connectActions(self):
# Connect File actions
self.newAction.triggered.connect(self.newFile)
self.openAction.triggered.connect(self.openFile)
self.saveAction.triggered.connect(self.saveFile)
self.exitAction.triggered.connect(self.close)
# Connect Edit actions
self.copyAction.triggered.connect(self.copyContent)
self.pasteAction.triggered.connect(self.pasteContent)
self.cutAction.triggered.connect(self.cutContent)
# Connect Help actions
self.helpContentAction.triggered.connect(self.helpContent)
self.aboutAction.triggered.connect(self.about)
# Connect Open Recent to dynamically populate it
self.openRecentMenu.aboutToShow.connect(self.populateOpenRecent)
# Slots
def newFile(self):
# Logic for creating a new file goes here...
self.centralWidget.setText("<b>File > New</b> clicked")
def openFile(self):
# Logic for opening an existing file goes here...
self.centralWidget.setText("<b>File > Open...</b> clicked")
def saveFile(self):
# Logic for saving a file goes here...
self.centralWidget.setText("<b>File > Save</b> clicked")
def copyContent(self):
# Logic for copying content goes here...
self.centralWidget.setText("<b>Edit > Copy</b> clicked")
def pasteContent(self):
# Logic for pasting content goes here...
self.centralWidget.setText("<b>Edit > Pate</b> clicked")
def cutContent(self):
# Logic for cutting content goes here...
self.centralWidget.setText("<b>Edit > Cut</b> clicked")
def helpContent(self):
# Logic for launching help goes here...
self.centralWidget.setText("<b>Help > Help Content...</b> clicked")
def about(self):
# Logic for showing an about dialog content goes here...
self.centralWidget.setText("<b>Help > About...</b> clicked")
def populateOpenRecent(self):
# Step 1. Remove the old options from the menu
self.openRecentMenu.clear()
# Step 2. Dynamically create the actions
actions = []
filenames = [f"File-{n}" for n in range(5)]
for filename in filenames:
action = QAction(filename, self)
action.triggered.connect(partial(self.openRecentFile, filename))
actions.append(action)
# Step 3. Add the actions to the menu
self.openRecentMenu.addActions(actions)
def openRecentFile(self, filename):
# Logic for opening a recent file goes here...
self.centralWidget.setText(f"<b>{filename}</b> opened")
def getWordCount(self):
# Logic for computing the word count goes here...
return 42
if __name__ == "__main__":
# Create the application
app = QApplication(sys.argv)
# Create and show the main window
win = Window()
win.show()
# Run the event loop
sys.exit(app.exec_())
# Python Practice Problems
Unittest stubs for ["Python Practice Problems."](https://realpython.com/python-practice-problems/)
## Running the Tests
To run the test for a given problem, use `unittest` from the Python standard library;
```console
$ python -m unittest integersums.py
```
The above example will run the unit tests for the first practice problem.
\ No newline at end of file
#!/usr/bin/env python3
""" Caesar Cipher
A caesar cipher is a simple substitution cipher where each letter of the
plain text is substituted with a letter found by moving 'n' places down the
alphabet. For an example, if the input plain text is:
abcd xyz
and the shift value, n, is 4. The encrypted text would be:
efgh bcd
You are to write a function which accepts two arguments, a plain-text
message and a number of letters to shift in the cipher. The function will
return an encrypted string with all letters being transformed while all
punctuation and whitespace remains unchanged.
Note: You can assume the plain text is all lowercase ascii, except for
whitespace and punctuation.
"""
import unittest
def caesar(plain_text, shift_num=1):
# TODO: Your code goes here!
result = plain_text
return result
class CaesarTestCase(unittest.TestCase):
def test_a(self):
start = "aaa"
result = caesar(start, 1)
self.assertEqual(result, "bbb")
result = caesar(start, 5)
self.assertEqual(result, "fff")
def test_punctuation(self):
start = "aaa.bbb"
result = caesar(start, 1)
self.assertEqual(result, "bbb.ccc")
result = caesar(start, -1)
self.assertEqual(result, "zzz.aaa")
def test_whitespace(self):
start = "aaa bb b"
result = caesar(start, 1)
self.assertEqual(result, "bbb cc c")
result = caesar(start, 3)
self.assertEqual(result, "ddd ee e")
def test_wraparound(self):
start = "abc"
result = caesar(start, -1)
self.assertEqual(result, "zab")
result = caesar(start, -2)
self.assertEqual(result, "yza")
result = caesar(start, -3)
self.assertEqual(result, "xyz")
start = "xyz"
result = caesar(start, 1)
self.assertEqual(result, "yza")
result = caesar(start, 2)
self.assertEqual(result, "zab")
result = caesar(start, 3)
self.assertEqual(result, "abc")
if __name__ == "__main__":
unittest.main()
#!/usr/bin/env python3
""" Sum of Integers Up To n
Write a function, add_it_up, which returns the sum of the integers from 0
to the single integer input parameter.
The function should return 0 if a non-integer is passed in.
"""
import unittest
def add_it_up(n):
# TODO: Your code goes here!
return n
class IntegerSumTestCase(unittest.TestCase):
def test_to_ten(self):
results = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]
for n in range(10):
self.assertEqual(add_it_up(n), results[n])
def test_string(self):
self.assertEqual(add_it_up("testing"), 0)
def test_float(self):
self.assertEqual(add_it_up(0.124), 0)
def test_negative(self):
self.assertEqual(add_it_up(-19), 0)
if __name__ == "__main__":
unittest.main()
#!/usr/bin/env python3
""" log parser
Accepts a filename on the command line. The file is a linux-like log file
from a system you are debugging. Mixed in among the various statements are
messages indicating the state of the device. They look like:
Jul 11 16:11:51:490 [139681125603136] dut: Device State: ON
The device state message has many possible values, but this program only
cares about three: ON, OFF, and ERR.
Your program will parse the given log file and print out a report giving
how long the device was ON, and the time stamp of any ERR conditions.
"""
if __name__ == "__main__":
# TODO: Your code goes here
print("There are no unit tests for logparse.")
#!/usr/bin/env python3
""" Sudoku Solver
NOTE: A description of the Sudoku puzzle can be found at:
https://en.wikipedia.org/wiki/Sudoku
Given a string in SDM format, described below, write a program to find and
return the solution for the Sudoku puzzle given in the string. The solution
should be returned in the same SDM format as the input.
Some puzzles will not be solvable. In that case, return the string
"Unsolvable".
The general sdx format is described here:
http://www.sudocue.net/fileformats.php
For our purposes, each SDX string will be a sequence of 81 digits, one for
each position on the Sudoku puzzle. Known numbers will be given and unknown
positions will have a zero value.
For example, this string of digits (split onto two lines for readability):
0040060790000006020560923000780610305090004
06020540890007410920105000000840600100
represents this starting Sudoku puzzle:
0 0 4 0 0 6 0 7 9
0 0 0 0 0 0 6 0 2
0 5 6 0 9 2 3 0 0
0 7 8 0 6 1 0 3 0
5 0 9 0 0 0 4 0 6
0 2 0 5 4 0 8 9 0
0 0 7 4 1 0 9 2 0
1 0 5 0 0 0 0 0 0
8 4 0 6 0 0 1 0 0
The unit tests provide may take a while to run, so be patient.
"""
import unittest
def sudoku_solve(input_string):
# TODO: Your code goes here!
return input_string
class SudokuSolverTestCase(unittest.TestCase):
problems = [
"00400607900000060205609230007806103050900040602054089000741092010500"
"0000840600100",
"01640000020000900040000006207023010010000000300308704096000000500080"
"0007000006820",
"04900860500300700000000003000040080006081502000100900001000000000060"
"0400804500390",
"76050000000006000800000040320040080008000003000500100780900000060001"
"0000000003041",
"00060500000302080004509027050000000106200054040000000709806045000604"
"0700000203000",
"40900070500001000000620780020000000900370420080000000400280150000006"
"0000905000406",
"00001003004007050100200800668000000300030200030000004520050080080104"
"0020090020000",
"08007003026005001800000040000060200039001008600070900000400080081004"
"0052050090070",
"00009300600080090002000610000008005300600020037005000000250004000100"
"9000700130007",
]
expected = [
"28413657991375468275689234147896123553928741662154389736741592819532"
"8764842679153",
"31645297828567931449731856287923415614296578365318724996872143552184"
"3697734596821",
"14923867562395714875814623993547286146781592328136975431679458259268"
"3417874521396",
"76354812942136975895817246329743681518679523434582169781925437663491"
"7582572683941",
"82967531467312489514539827658743692196281754343195268739876145221654"
"9738754283169",
"41963872572851964353624789125418637919375426886792315464289153737146"
"5982985372416",
"76891543294327658151243879668519427317435296832968714523756981485174"
"3629496821357",
"48197623526745391893582146717863254939251478654678932172416589381934"
"7652653298174",
"Unsolvable",
]
def test_solver(self):
for index, problem in enumerate(self.problems):
print(f"Testing puzzle {index+1}")
result = sudoku_solve(problem)
self.assertEqual(result, self.expected[index])
if __name__ == "__main__":
unittest.main()
Jul 11 16:11:51:490 [139681125603136] dut: --------------------------------------------------------------------------------------------------------
Jul 11 16:11:51:490 [139681125603136] dut: Revision : 64180
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(duthash_remove)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(duthash_remove)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(duthash_remove)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(duthash_remove)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(init_dut)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(init_dut)
Jul 11 16:11:51:490 [139681125603136] dut: set hglob.mydut = 0x16f2f20
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(init_dut)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(init_dut)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /dom/dut 10.220.40.191/48002 0x16f37c0
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /TunnelPerformance/perfw2k8-17 169.254.18.44/48002 0x16f40d0
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /db/db-1-sh02 10.220.43.160/48002 0x16f56a0
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /bci-ci-sec-rhel6_domain/bci-ci-sec-solx64 10.220.42.66/48002 0x16f5f40
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: Device State: ON
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /dom/testcent7 10.220.40.49/48002 0x16f7080
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /cent1_domain/win11 10.220.40.126/48002 0x16f8380
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /dom/testwin2012 10.220.40.88/48002 0x16f8e00
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /Primary_dom/Secondary 10.220.42.244/48002 0x16f9870
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /bci-ci-sec-rhel6_domain/bci-ci-sec-win2 10.220.42.67/48002 0x16fa110
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /TunnelPerformance/perfw2k8-15 169.254.120.22/48002 0x16fa9b0
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:490 [139681125603136] dut: dutinfo create: /AC2Primary_domain/AC2Primary_dut 10.220.42.174/48002 0x16fb4d0
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /DE279854dom/DE279854primh 10.220.41.20/48002 0x16fbd70
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /bci-ci-sec-rhel6_domain/bci-ci-sec-rhel7 10.220.42.62/48002 0x16fc830
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /mbonnetrh67_domain/mbonnetcent64-1 10.220.40.252/48002 0x16fd0d0
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /dom/testwin2012_2 10.220.40.131/48002 0x16fd9c0
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /Win2k12Prim847_domain/Win2k12Prim847_dut 10.220.41.92/48002 0x16feee0
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /Primary_dom/Primary_dut 10.220.42.217/48002 0x16ff780
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /AC2Primary_domain/SaaSTS 10.220.41.139/48002 0x1700060
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /db/db-1-lh02 10.220.42.118/48002 0x17009c0
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /TunnelPerformance/tswin16 10.220.41.128/48002 0x1701db0
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /TunnelPerformance/TCrhel6 10.220.40.160/48002 0x17026a0
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: dutinfo create: /mbonnetw2k8sand_domain/mikebw2k8sandh2 10.220.41.109/48002 0x1703a90
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: duthash_read - 27 duts read from cache
Jul 11 16:11:51:491 [139681125603136] dut: cfgReader file open: dut.cfg
Jul 11 16:11:51:491 [139681125603136] dut: cfgReader file close: dut.cfg
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_LOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK? hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: MUTEX_UNLOCK hash(dutinfo_create)
Jul 11 16:11:51:491 [139681125603136] dut: Added 3 static duts from cache
Jul 11 16:11:51:491 [139681125603136] dut: dut SEC: session=1804560451
Jul 11 16:11:51:492 [139681125603136] dut: dut SEC: expire=21600
Jul 11 16:11:51:492 [139681125603136] dut: dut SEC: version=1688
Jul 11 16:11:51:492 [139681125603136] dut: dut SEC: ignore IP=no
Jul 11 16:11:51:492 [139681125603136] dut: dut SEC: auth_mode=0000
Jul 11 16:11:51:492 [139681125603136] dut: dut SEC: trusted IPs=
Jul 11 16:11:51:495 [139681125603136] dut: dut SEC: ON
Jul 11 16:11:51:495 [139681125603136] dut: nimGetIpList called with buffer size 40960
Jul 11 16:11:51:495 [139681125603136] dut: nimGetIpList - skipping loopback address 127.0.0.1
Jul 11 16:11:51:495 [139681125603136] dut: nimGetIpList - skipping loopback address ::1
Jul 11 16:11:51:495 [139681125603136] dut: nimGetIpList - found |||10.220.40.228|fc00:415::c9f1:5e35:cef2:ef8|fe80::e3c7:a9f2:3dd8:6450|
Jul 11 16:11:51:495 [139681125603136] dut: MUTEX_LOCK? hash(hsecInit)
Jul 11 16:11:51:495 [139681125603136] dut: MUTEX_LOCK hash(hsecInit)
Jul 11 16:11:51:495 [139681125603136] dut: MUTEX_UNLOCK? hash(hsecInit)
Jul 11 16:11:51:495 [139681125603136] dut: MUTEX_UNLOCK hash(hsecInit)
Jul 11 16:11:51:496 [139681125603136] dut: nimSessionServer - port = 48002
Jul 11 16:11:51:496 [139681125603136] dut: SSL - skipping SSL server setup - ssl_mode is 0 (off)
Jul 11 16:11:51:496 [139681125603136] dut: sockCheckLocalPort: port=48002, non-strict binding, checking all
Jul 11 16:11:51:496 [139681125603136] dut: sockCheckLocalPort: port=48002 sock=6, trying addr=--
Jul 11 16:11:51:496 [139681125603136] dut: sockCheckLocalPort - close 6
Jul 11 16:11:51:496 [139681125603136] dut: sockServer - new socket 6
Jul 11 16:11:51:496 [139681125603136] dut: sockServer:0x17279e0:0.0.0.0/48002
Jul 11 16:11:51:496 [139681125603136] dut: (nim_ldap_init_ssl) enter
Jul 11 16:11:51:496 [139681125603136] dut: (nim_ldap_init_ssl) ldapssl_client_init -> Success (0)
Jul 11 16:11:51:496 [139681125603136] dut: (nld_dll_load) leave have paging: true
Jul 11 16:11:51:496 [139681125603136] dut: (nim_ldap_init_ssl) done: OK (0)
Jul 11 16:11:51:496 [139681125603136] dut: (nim_ldap_cert_auto_verify_disable) ldapssl_set_verify_callback -> Success (0)
Jul 11 16:11:51:496 [139681125603136] dut: ----- dut started -----
Jul 11 16:11:51:496 [139681125603136] dut: log_level= 6 , log_file=dut.log
Jul 11 16:11:51:496 [139681125603136] dut: LDAP LIB = 1.22
Jul 11 16:11:51:496 [139681125603136] dut: -----
Jul 11 16:11:51:496 [139681125603136] dut: do_assign_to_list entered...
Jul 11 16:11:51:496 [139681125603136] dut: AssignToList - used 0 ms to lookup 1 users
Jul 11 16:11:51:496 [139681125603136] dut: do_assign_to_list finished... status: OK (0), time used: 0 ms
Jul 11 16:11:51:497 [139681125603136] dut: duti is starting in thread 78374656
Jul 11 16:11:51:497 [139681125603136] dut: sockConnect - new TCP socket fd=7
Jul 11 16:11:51:497 [139681004775168] dut: duti main thread started
Jul 11 16:11:51:497 [139681004775168] dut: nimSessionServer - port = 48002
Jul 11 16:11:51:497 [139681004775168] dut: SSL - skipping SSL server setup - ssl_mode is 0 (off)
Jul 11 16:11:51:497 [139681125603136] dut: SREQUEST: port_register ->10.220.40.228/48000
Jul 11 16:11:51:497 [139681004775168] dut: sockServer - new socket 8
Jul 11 16:11:51:497 [139681125603136] dut: head mtype=100 cmd=port_register seq=0 ts=1499811111 frm=10.220.40.228/55902 tout=20 addr= sid=lpW5VPKZ/DKdf80dKgf9jAADMTQ5OTgxMTE3MQFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:51:497 [139681125603136] dut: data name=dut port=48002
Jul 11 16:11:51:497 [139681004775168] dut: sockServer:0x7f0a00000930:0.0.0.0/48002
Jul 11 16:11:51:497 [139681125603136] dut: RREPLY: status=OK(0) <-10.220.40.228/48000 h=37 d=0
Jul 11 16:11:51:497 [139681125603136] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:51:497 [139681125603136] dut: sockClose:0x171ed40:10.220.40.228/55902
Jul 11 16:11:51:497 [139681125603136] dut: SREQUEST: _close ->10.220.40.228/48000
Jul 11 16:11:51:497 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811111 frm=10.220.40.228/55902 tout=20 addr= sid=lpW5VPKZ/DKdf80dKgf9jAADMTQ5OTgxMTE3MQFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:51:497 [139681125603136] dut: nimSessionServer - port = 48001
Jul 11 16:11:51:497 [139681125603136] dut: SSL - skipping SSL server setup - ssl_mode is 0 (off)
Jul 11 16:11:51:497 [139681125603136] dut: sockCheckLocalPort: port=48001, non-strict binding, checking all
Jul 11 16:11:51:497 [139681125603136] dut: sockCheckLocalPort: port=48001 sock=7, trying addr=--
Jul 11 16:11:51:497 [139681125603136] dut: sockCheckLocalPort - close 7
Jul 11 16:11:51:497 [139681125603136] dut: sockServer - new socket 7
Jul 11 16:11:51:497 [139681125603136] dut: sockServer:0x171e8a0:0.0.0.0/48001
Jul 11 16:11:51:497 [139681125603136] dut: sockConnect - new TCP socket fd=9
Jul 11 16:11:51:497 [139681125603136] dut: SREQUEST: port_register ->10.220.40.228/48000
Jul 11 16:11:51:497 [139681125603136] dut: head mtype=100 cmd=port_register seq=0 ts=1499811111 frm=10.220.40.228/55904 tout=20 addr= sid=lpW5VPKZ/DKdf80dKgf9jAADMTQ5OTgxMTE3MQFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:51:497 [139681125603136] dut: data name=spooler port=48001
Jul 11 16:11:51:497 [139681125603136] dut: RREPLY: status=OK(0) <-10.220.40.228/48000 h=37 d=0
Jul 11 16:11:51:497 [139681125603136] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:51:497 [139681125603136] dut: sockClose:0x173c860:10.220.40.228/55904
Jul 11 16:11:51:497 [139681125603136] dut: SREQUEST: _close ->10.220.40.228/48000
Jul 11 16:11:51:497 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811111 frm=10.220.40.228/55904 tout=20 addr= sid=lpW5VPKZ/DKdf80dKgf9jAADMTQ5OTgxMTE3MQFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:51:497 [139681125603136] dut: Spooler - initializing
Jul 11 16:11:51:497 [139681125603136] dut: validating character encoding of config file: dut.cfg
Jul 11 16:11:51:497 [139681125603136] dut: nimCharsetValidateFile: dut.cfg: no target charset
Jul 11 16:11:51:498 [139681125603136] dut: Messages will have their source extended with the origin value to ensure uniqueness
Jul 11 16:11:51:498 [139681125603136] dut: Removed 'q/temp/t_1'
Jul 11 16:11:51:498 [139681125603136] dut: Removed 'q/temp/t_2'
Jul 11 16:11:51:498 [139681125603136] dut: Removed 'q/temp'
Jul 11 16:11:51:498 [139681125603136] dut: System has 2 available cores, default spooler inbound thread pool size is 2
Jul 11 16:11:51:498 [139681125603136] dut: Using default inbound thread pool size
Jul 11 16:11:51:498 [139681125603136] dut: newRoute name=data_engine pr=0x173d100
Jul 11 16:11:51:498 [139681125603136] dut: Configured ATTACH queue route 'data_engine' for 'QOS_MESSAGE,QOS_DEFINITION' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:498 [139681125603136] dut: newRoute name=baseline_engine.BASELINE_CONFIG pr=0x173dc90
Jul 11 16:11:51:498 [139680926398208] dut: Queue management thread for 'data_engine' started
Jul 11 16:11:51:498 [139681125603136] dut: Configured ATTACH queue route 'baseline_engine.BASELINE_CONFIG' for 'BASELINE_CONFIG' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:498 [139681125603136] dut: newRoute name=prediction_engine.PREDICTION_CONFIG pr=0x173e980
Jul 11 16:11:51:498 [139680918005504] dut: Queue management thread for 'baseline_engine.BASELINE_CONFIG' started
Jul 11 16:11:51:498 [139680926398208] dut: Queue 'data_engine' has queued file '3951.sds' for future processing
Jul 11 16:11:51:499 [139681125603136] dut: Configured ATTACH queue route 'prediction_engine.PREDICTION_CONFIG' for 'PREDICTION_CONFIG' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:499 [139681125603136] dut: newRoute name=action_manager pr=0x173f650
Jul 11 16:11:51:499 [139680926398208] dut: Queue 'data_engine' has 1 existing data files
Jul 11 16:11:51:499 [139680926398208] dut: Queue 'data_engine' will start reading at file sequence no. 3951
Jul 11 16:11:51:499 [139680926398208] dut: Queue 'data_engine' will start writing at file sequence no. 3952
Jul 11 16:11:51:499 [139680909612800] dut: Queue management thread for 'prediction_engine.PREDICTION_CONFIG' started
Jul 11 16:11:51:499 [139680926398208] dut: Queue 'data_engine' opened file '3952.sds' for writing
Jul 11 16:11:51:499 [139680901220096] dut: Initalizing read file '3951.sds' for 'data_engine'
Jul 11 16:11:51:499 [139680918005504] dut: Queue 'baseline_engine.BASELINE_CONFIG' has queued file '157.sds' for future processing
Jul 11 16:11:51:499 [139680901220096] dut: Read file '3951.sds' initialized for 'data_engine', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:499 [139681125603136] dut: Configured ATTACH queue route 'action_manager' for 'ems_action' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:499 [139681125603136] dut: newRoute name=legacy_alarm_manager pr=0x1740320
Jul 11 16:11:51:499 [139680892827392] dut: Queue management thread for 'action_manager' started
Jul 11 16:11:51:500 [139680884434688] dut: Initalizing read file '157.sds' for 'baseline_engine.BASELINE_CONFIG'
Jul 11 16:11:51:500 [139680884434688] dut: Read file '157.sds' initialized for 'baseline_engine.BASELINE_CONFIG', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:500 [139680909612800] dut: Queue 'prediction_engine.PREDICTION_CONFIG' has queued file '157.sds' for future processing
Jul 11 16:11:51:500 [139681125603136] dut: Configured ATTACH queue route 'legacy_alarm_manager' for 'alarm' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:500 [139681125603136] dut: newRoute name=alarm_manager pr=0x1740ff0
Jul 11 16:11:51:500 [139680918005504] dut: Queue 'baseline_engine.BASELINE_CONFIG' has 1 existing data files
Jul 11 16:11:51:500 [139680918005504] dut: Queue 'baseline_engine.BASELINE_CONFIG' will start reading at file sequence no. 157
Jul 11 16:11:51:500 [139680918005504] dut: Queue 'baseline_engine.BASELINE_CONFIG' will start writing at file sequence no. 158
Jul 11 16:11:51:500 [139680918005504] dut: Queue 'baseline_engine.BASELINE_CONFIG' opened file '158.sds' for writing
Jul 11 16:11:51:500 [139680892827392] dut: Queue 'action_manager' has queued file '125.sds' for future processing
Jul 11 16:11:51:500 [139681125603136] dut: Configured ATTACH queue route 'alarm_manager' for 'enriched_events' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:500 [139681125603136] dut: newRoute name=ems pr=0x1741cc0
Jul 11 16:11:51:500 [139680909612800] dut: Queue 'prediction_engine.PREDICTION_CONFIG' has 1 existing data files
Jul 11 16:11:51:500 [139680909612800] dut: Queue 'prediction_engine.PREDICTION_CONFIG' will start reading at file sequence no. 157
Jul 11 16:11:51:500 [139680909612800] dut: Queue 'prediction_engine.PREDICTION_CONFIG' will start writing at file sequence no. 158
Jul 11 16:11:51:500 [139680909612800] dut: Queue 'prediction_engine.PREDICTION_CONFIG' opened file '158.sds' for writing
Jul 11 16:11:51:500 [139680892827392] dut: Queue 'action_manager' has 1 existing data files
Jul 11 16:11:51:500 [139680892827392] dut: Queue 'action_manager' will start reading at file sequence no. 125
Jul 11 16:11:51:500 [139680892827392] dut: Queue 'action_manager' will start writing at file sequence no. 126
Jul 11 16:11:51:501 [139680892827392] dut: Queue 'action_manager' opened file '126.sds' for writing
Jul 11 16:11:51:501 [139680884434688] dut: Queue 'baseline_engine.BASELINE_CONFIG' file '157.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:501 [139681125603136] dut: Configured ATTACH queue route 'ems' for 'TOT_RULE_CONFIG' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:501 [139681125603136] dut: newRoute name=event_manager pr=0x1742990
Jul 11 16:11:51:502 [139681125603136] dut: Configured ATTACH queue route 'event_manager' for 'event' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:502 [139681125603136] dut: newRoute name=probeDiscovery pr=0x1743660
Jul 11 16:11:51:502 [139681125603136] dut: Configured ATTACH queue route 'probeDiscovery' for 'probe_discovery' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:502 [139681125603136] dut: newRoute name=udm_inventory pr=0x17440f0
Jul 11 16:11:51:502 [139681125603136] dut: Configured ATTACH queue route 'udm_inventory' for 'udm_inventory' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:502 [139681125603136] dut: newRoute name=emailgtw pr=0x1745a90
Jul 11 16:11:51:502 [139681125603136] dut: Configured ATTACH queue route 'emailgtw' for 'EMAIL' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:502 [139681125603136] dut: newRoute name=ems_alarm_new pr=0x1746760
Jul 11 16:11:51:502 [139681125603136] dut: Configured ATTACH queue route 'ems_alarm_new' for 'alarm_new' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:502 [139681125603136] dut: newRoute name=ems_alarm_update pr=0x1747430
Jul 11 16:11:51:502 [139681125603136] dut: Configured ATTACH queue route 'ems_alarm_update' for 'alarm_update' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:502 [139681125603136] dut: newRoute name=ems_alarm_assign pr=0x1748100
Jul 11 16:11:51:502 [139681125603136] dut: Configured ATTACH queue route 'ems_alarm_assign' for 'alarm_assign' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:502 [139681125603136] dut: newRoute name=ems_alarm_close pr=0x1748dd0
Jul 11 16:11:51:502 [139681125603136] dut: Configured ATTACH queue route 'ems_alarm_close' for 'alarm_close' (bulk:100 min:0 wait:0 timeout:60)
Jul 11 16:11:51:502 [139681125603136] dut: spooler_main_thread - has started in thread 139680313992960
Jul 11 16:11:51:502 [139681125603136] dut: topology - main thread - cfg - on = 1, max_threads = 10, restart_wait = 60 seconds
Jul 11 16:11:51:502 [139681125603136] dut: topology - main thread - started
Jul 11 16:11:51:502 [139680574068480] dut: Queue management thread for 'alarm_manager' started
Jul 11 16:11:51:502 [139680574068480] dut: Queue 'alarm_manager' has queued file '282.sds' for future processing
Jul 11 16:11:51:502 [139680574068480] dut: Queue 'alarm_manager' has 1 existing data files
Jul 11 16:11:51:502 [139680574068480] dut: Queue 'alarm_manager' will start reading at file sequence no. 282
Jul 11 16:11:51:502 [139680574068480] dut: Queue 'alarm_manager' will start writing at file sequence no. 283
Jul 11 16:11:51:502 [139680574068480] dut: Queue 'alarm_manager' opened file '283.sds' for writing
Jul 11 16:11:51:502 [139680548890368] dut: Queue sender thread for 'baseline_engine.BASELINE_CONFIG' started
Jul 11 16:11:51:502 [139680540497664] dut: Queue sender thread for 'prediction_engine.PREDICTION_CONFIG' started
Jul 11 16:11:51:502 [139680381134592] dut: Queue management thread for 'event_manager' started
Jul 11 16:11:51:502 [139680381134592] dut: Queue 'event_manager' has queued file '285.sds' for future processing
Jul 11 16:11:51:503 [139680381134592] dut: Queue 'event_manager' has 1 existing data files
Jul 11 16:11:51:503 [139680381134592] dut: Queue 'event_manager' will start reading at file sequence no. 285
Jul 11 16:11:51:503 [139680381134592] dut: Queue 'event_manager' will start writing at file sequence no. 286
Jul 11 16:11:51:503 [139680381134592] dut: Queue 'event_manager' opened file '286.sds' for writing
Jul 11 16:11:51:503 [139680884434688] dut: Queue management thread for 'probeDiscovery' started
Jul 11 16:11:51:503 [139680884434688] dut: Queue 'probeDiscovery' has queued file '187.sds' for future processing
Jul 11 16:11:51:503 [139680884434688] dut: Queue 'probeDiscovery' has 1 existing data files
Jul 11 16:11:51:503 [139680884434688] dut: Queue 'probeDiscovery' will start reading at file sequence no. 187
Jul 11 16:11:51:503 [139680884434688] dut: Queue 'probeDiscovery' will start writing at file sequence no. 188
Jul 11 16:11:51:503 [139680884434688] dut: Queue 'probeDiscovery' opened file '188.sds' for writing
Jul 11 16:11:51:503 [139680288814848] dut: do_assign_to_list entered...
Jul 11 16:11:51:503 [139680288814848] dut: AssignToList - used 0 ms to lookup 1 users
Jul 11 16:11:51:503 [139680288814848] dut: do_assign_to_list finished... status: OK (0), time used: 0 ms
Jul 11 16:11:51:503 [139680347563776] dut: Queue management thread for 'ems_alarm_new' started
Jul 11 16:11:51:503 [139680347563776] dut: Queue 'ems_alarm_new' has queued file '89.sds' for future processing
Jul 11 16:11:51:503 [139680347563776] dut: Queue 'ems_alarm_new' has 1 existing data files
Jul 11 16:11:51:503 [139680347563776] dut: Queue 'ems_alarm_new' will start reading at file sequence no. 89
Jul 11 16:11:51:503 [139680347563776] dut: Queue 'ems_alarm_new' will start writing at file sequence no. 90
Jul 11 16:11:51:503 [139680347563776] dut: Queue 'ems_alarm_new' opened file '90.sds' for writing
Jul 11 16:11:51:503 [139680330778368] dut: Queue management thread for 'ems_alarm_assign' started
Jul 11 16:11:51:503 [139680330778368] dut: Queue 'ems_alarm_assign' has queued file '89.sds' for future processing
Jul 11 16:11:51:503 [139680330778368] dut: Queue 'ems_alarm_assign' has 1 existing data files
Jul 11 16:11:51:503 [139680330778368] dut: Queue 'ems_alarm_assign' will start reading at file sequence no. 89
Jul 11 16:11:51:503 [139680330778368] dut: Queue 'ems_alarm_assign' will start writing at file sequence no. 90
Jul 11 16:11:51:503 [139680330778368] dut: Queue 'ems_alarm_assign' opened file '90.sds' for writing
Jul 11 16:11:51:503 [139680322385664] dut: Queue management thread for 'ems_alarm_close' started
Jul 11 16:11:51:503 [139680322385664] dut: Queue 'ems_alarm_close' has queued file '89.sds' for future processing
Jul 11 16:11:51:503 [139680322385664] dut: Queue 'ems_alarm_close' has 1 existing data files
Jul 11 16:11:51:503 [139680322385664] dut: Queue 'ems_alarm_close' will start reading at file sequence no. 89
Jul 11 16:11:51:503 [139680322385664] dut: Queue 'ems_alarm_close' will start writing at file sequence no. 90
Jul 11 16:11:51:503 [139680322385664] dut: Queue 'ems_alarm_close' opened file '90.sds' for writing
Jul 11 16:11:51:504 [139680305600256] dut: cfgReader file close: dut.cfg
Jul 11 16:11:51:504 [139680305600256] dut: [-1040206080] started worker thread (0xc1ffb700)
Jul 11 16:11:51:504 [139680305600256] dut: [-1048598784] started worker thread (0xc17fa700)
Jul 11 16:11:51:504 [139680305600256] dut: [-1056991488] started worker thread (0xc0ff9700)
Jul 11 16:11:51:504 [139680305600256] dut: [-1207961856] started worker thread (0xb7fff700)
Jul 11 16:11:51:504 [139680305600256] dut: [-1216354560] started worker thread (0xb77fe700)
Jul 11 16:11:51:504 [139680305600256] dut: [-1224747264] started worker thread (0xb6ffd700)
Jul 11 16:11:51:504 [139680305600256] dut: [-1233139968] started worker thread (0xb67fc700)
Jul 11 16:11:51:504 [139680305600256] dut: [-1241532672] started worker thread (0xb5ffb700)
Jul 11 16:11:51:504 [139680305600256] dut: [-1249925376] started worker thread (0xb57fa700)
Jul 11 16:11:51:504 [139680305600256] dut: [-1258318080] started worker thread (0xb4ff9700)
Jul 11 16:11:51:504 [139680372741888] dut: Queue management thread for 'udm_inventory' started
Jul 11 16:11:51:504 [139680372741888] dut: Queue 'udm_inventory' has queued file '187.sds' for future processing
Jul 11 16:11:51:504 [139680372741888] dut: Queue 'udm_inventory' has 1 existing data files
Jul 11 16:11:51:504 [139680372741888] dut: Queue 'udm_inventory' will start reading at file sequence no. 187
Jul 11 16:11:51:504 [139680372741888] dut: Queue 'udm_inventory' will start writing at file sequence no. 188
Jul 11 16:11:51:504 [139680372741888] dut: Queue 'udm_inventory' opened file '188.sds' for writing
Jul 11 16:11:51:504 [139680280422144] dut: Initalizing read file '282.sds' for 'alarm_manager'
Jul 11 16:11:51:505 [139680280422144] dut: Read file '282.sds' initialized for 'alarm_manager', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:505 [139680280422144] dut: Queue 'alarm_manager' file '282.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:505 [139680179808000] dut: Queue sender thread for 'event_manager' started
Jul 11 16:11:51:505 [139680188200704] dut: Initalizing read file '285.sds' for 'event_manager'
Jul 11 16:11:51:505 [139680188200704] dut: Read file '285.sds' initialized for 'event_manager', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:505 [139680901220096] dut: Queue 'data_engine' file '3951.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:505 [139680590853888] dut: Queue management thread for 'legacy_alarm_manager' started
Jul 11 16:11:51:505 [139680590853888] dut: Queue 'legacy_alarm_manager' has queued file '122.sds' for future processing
Jul 11 16:11:51:505 [139680590853888] dut: Queue 'legacy_alarm_manager' has 1 existing data files
Jul 11 16:11:51:505 [139680590853888] dut: Queue 'legacy_alarm_manager' will start reading at file sequence no. 122
Jul 11 16:11:51:505 [139680590853888] dut: Queue 'legacy_alarm_manager' will start writing at file sequence no. 123
Jul 11 16:11:51:505 [139680590853888] dut: Queue 'legacy_alarm_manager' opened file '123.sds' for writing
Jul 11 16:11:51:505 [139680876041984] dut: Queue sender thread for 'data_engine' started
Jul 11 16:11:51:505 [139680188200704] dut: Queue 'event_manager' file '285.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:505 [139680582461184] dut: Initalizing read file '157.sds' for 'prediction_engine.PREDICTION_CONFIG'
Jul 11 16:11:51:505 [139680582461184] dut: Read file '157.sds' initialized for 'prediction_engine.PREDICTION_CONFIG', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:505 [139680582461184] dut: Queue 'prediction_engine.PREDICTION_CONFIG' file '157.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:505 [139680565675776] dut: Initalizing read file '125.sds' for 'action_manager'
Jul 11 16:11:51:506 [139680163022592] dut: Queue sender thread for 'probeDiscovery' started
Jul 11 16:11:51:506 [139679869409024] dut: [-1056991488] thread started
Jul 11 16:11:51:506 [139679693260544] dut: [-1233139968] thread started
Jul 11 16:11:51:506 [139679676475136] dut: [-1249925376] thread started
Jul 11 16:11:51:506 [139679710045952] dut: [-1216354560] thread started
Jul 11 16:11:51:506 [139680565675776] dut: Read file '125.sds' initialized for 'action_manager', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:506 [139680171415296] dut: Initalizing read file '187.sds' for 'probeDiscovery'
Jul 11 16:11:51:506 [139680171415296] dut: Read file '187.sds' initialized for 'probeDiscovery', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:506 [139680565675776] dut: Queue 'action_manager' file '125.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:506 [139680557283072] dut: Queue management thread for 'ems' started
Jul 11 16:11:51:506 [139680557283072] dut: Queue 'ems' has queued file '157.sds' for future processing
Jul 11 16:11:51:506 [139680557283072] dut: Queue 'ems' has 1 existing data files
Jul 11 16:11:51:506 [139680557283072] dut: Queue 'ems' will start reading at file sequence no. 157
Jul 11 16:11:51:506 [139680557283072] dut: Queue 'ems' will start writing at file sequence no. 158
Jul 11 16:11:51:506 [139680171415296] dut: Queue 'probeDiscovery' file '187.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:506 [139680557283072] dut: Queue 'ems' opened file '158.sds' for writing
Jul 11 16:11:51:506 [139680146237184] dut: Initalizing read file '89.sds' for 'ems_alarm_new'
Jul 11 16:11:51:506 [139680146237184] dut: Read file '89.sds' initialized for 'ems_alarm_new', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:506 [139680389527296] dut: Queue sender thread for 'action_manager' started
Jul 11 16:11:51:506 [139680146237184] dut: Queue 'ems_alarm_new' file '89.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:506 [139680355956480] dut: Queue management thread for 'emailgtw' started
Jul 11 16:11:51:506 [139680355956480] dut: Queue 'emailgtw' has queued file '75.sds' for future processing
Jul 11 16:11:51:506 [139680355956480] dut: Queue 'emailgtw' has 1 existing data files
Jul 11 16:11:51:506 [139680355956480] dut: Queue 'emailgtw' will start reading at file sequence no. 75
Jul 11 16:11:51:506 [139680355956480] dut: Queue 'emailgtw' will start writing at file sequence no. 76
Jul 11 16:11:51:506 [139680355956480] dut: Queue 'emailgtw' opened file '76.sds' for writing
Jul 11 16:11:51:506 [139680339171072] dut: Queue management thread for 'ems_alarm_update' started
Jul 11 16:11:51:506 [139680339171072] dut: Queue 'ems_alarm_update' has queued file '91.sds' for future processing
Jul 11 16:11:51:506 [139680339171072] dut: Queue 'ems_alarm_update' has 1 existing data files
Jul 11 16:11:51:506 [139680339171072] dut: Queue 'ems_alarm_update' will start reading at file sequence no. 91
Jul 11 16:11:51:506 [139680339171072] dut: Queue 'ems_alarm_update' will start writing at file sequence no. 92
Jul 11 16:11:51:506 [139680339171072] dut: Queue 'ems_alarm_update' opened file '92.sds' for writing
Jul 11 16:11:51:506 [139680313992960] dut: spooler main thread started
Jul 11 16:11:51:506 [139680297207552] dut: topology - main thread - starting worker thread pool ...
Jul 11 16:11:51:506 [139680297207552] dut: [-1476430080] started worker thread (0xa7ff7700)
Jul 11 16:11:51:506 [139680297207552] dut: [-1484822784] started worker thread (0xa77f6700)
Jul 11 16:11:51:506 [139680297207552] dut: [-1493215488] started worker thread (0xa6ff5700)
Jul 11 16:11:51:506 [139680297207552] dut: [-1501608192] started worker thread (0xa67f4700)
Jul 11 16:11:51:506 [139680297207552] dut: [-1510000896] started worker thread (0xa5ff3700)
Jul 11 16:11:51:506 [139680297207552] dut: [-1518393600] started worker thread (0xa57f2700)
Jul 11 16:11:51:506 [139680297207552] dut: [-1526786304] started worker thread (0xa4ff1700)
Jul 11 16:11:51:506 [139680297207552] dut: [-1535179008] started worker thread (0xa47f0700)
Jul 11 16:11:51:506 [139680297207552] dut: [-1543571712] started worker thread (0xa3fef700)
Jul 11 16:11:51:506 [139680297207552] dut: [-1551964416] started worker thread (0xa37ee700)
Jul 11 16:11:51:506 [139680272029440] dut: Queue sender thread for 'alarm_manager' started
Jul 11 16:11:51:506 [139679911372544] dut: Queue sender thread for 'ems_alarm_assign' started
Jul 11 16:11:51:506 [139679894587136] dut: Queue sender thread for 'ems_alarm_close' started
Jul 11 16:11:51:506 [139679718438656] dut: [-1207961856] thread started
Jul 11 16:11:51:506 [139679877801728] dut: [-1048598784] thread started
Jul 11 16:11:51:506 [139679701653248] dut: [-1224747264] thread started
Jul 11 16:11:51:506 [139679919765248] dut: Initalizing read file '89.sds' for 'ems_alarm_assign'
Jul 11 16:11:51:506 [139679684867840] dut: [-1241532672] thread started
Jul 11 16:11:51:506 [139679919765248] dut: Read file '89.sds' initialized for 'ems_alarm_assign', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:506 [139680901220096] dut: Initalizing read file '122.sds' for 'legacy_alarm_manager'
Jul 11 16:11:51:506 [139679919765248] dut: Queue 'ems_alarm_assign' file '89.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:506 [139680901220096] dut: Read file '122.sds' initialized for 'legacy_alarm_manager', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:506 [139679902979840] dut: Initalizing read file '89.sds' for 'ems_alarm_close'
Jul 11 16:11:51:507 [139679902979840] dut: Read file '89.sds' initialized for 'ems_alarm_close', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:507 [139679902979840] dut: Queue 'ems_alarm_close' file '89.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:507 [139679886194432] dut: [-1040206080] thread started
Jul 11 16:11:51:507 [139679668082432] dut: [-1258318080] thread started
Jul 11 16:11:51:506 [139680137844480] dut: Queue sender thread for 'ems_alarm_new' started
Jul 11 16:11:51:507 [139679517112064] dut: Initalizing read file '187.sds' for 'udm_inventory'
Jul 11 16:11:51:507 [139680901220096] dut: Queue 'legacy_alarm_manager' file '122.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:506 [139679508719360] dut: Queue sender thread for 'udm_inventory' started
Jul 11 16:11:51:507 [139680280422144] dut: Queue sender thread for 'legacy_alarm_manager' started
Jul 11 16:11:51:507 [139680582461184] dut: Initalizing read file '91.sds' for 'ems_alarm_update'
Jul 11 16:11:51:507 [139679517112064] dut: Read file '187.sds' initialized for 'udm_inventory', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:507 [139680582461184] dut: Read file '91.sds' initialized for 'ems_alarm_update', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:507 [139680582461184] dut: Queue 'ems_alarm_update' file '91.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:507 [139679500326656] dut: Queue sender thread for 'ems_alarm_update' started
Jul 11 16:11:51:507 [139679491933952] dut: Post input handling thread - started
Jul 11 16:11:51:507 [139679475148544] dut: spooler subscriber management thread started
Jul 11 16:11:51:507 [139679458363136] dut: There are 0 objects waiting on 2 threads
Jul 11 16:11:51:507 [139679449970432] dut: [-1476430080] thread started
Jul 11 16:11:51:507 [139679433185024] dut: [-1493215488] thread started
Jul 11 16:11:51:507 [139679416399616] dut: [-1510000896] thread started
Jul 11 16:11:51:507 [139679399614208] dut: [-1526786304] thread started
Jul 11 16:11:51:507 [139679391221504] dut: [-1535179008] thread started
Jul 11 16:11:51:507 [139679374436096] dut: [-1551964416] thread started
Jul 11 16:11:51:507 [139679441577728] dut: [-1484822784] thread started
Jul 11 16:11:51:507 [139679424792320] dut: [-1501608192] thread started
Jul 11 16:11:51:507 [139679408006912] dut: [-1518393600] thread started
Jul 11 16:11:51:507 [139679382828800] dut: [-1543571712] thread started
Jul 11 16:11:51:507 [139679483541248] dut: Post input handling thread - started
Jul 11 16:11:51:507 [139679517112064] dut: Queue 'udm_inventory' file '187.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:507 [139680188200704] dut: Queue sender thread for 'emailgtw' started
Jul 11 16:11:51:507 [139680146237184] dut: Initalizing read file '75.sds' for 'emailgtw'
Jul 11 16:11:51:507 [139680146237184] dut: Read file '75.sds' initialized for 'emailgtw', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:507 [139680146237184] dut: Queue 'emailgtw' file '75.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:507 [139680565675776] dut: Initalizing read file '157.sds' for 'ems'
Jul 11 16:11:51:507 [139680565675776] dut: Read file '157.sds' initialized for 'ems', 0 msgs found (@ pos 0), 0 ms used
Jul 11 16:11:51:507 [139680565675776] dut: Queue 'ems' file '157.sds' does not contain sendable msgs, deleted
Jul 11 16:11:51:507 [139680171415296] dut: Queue sender thread for 'ems' started
Jul 11 16:11:52:213 [139681125603136] dut: sockAccept: new socket fd=25
Jul 11 16:11:52:213 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x174a1e0 fd=25 10.238.40.228/48002<-10.238.40.143/37088
Jul 11 16:11:52:213 [139681125603136] dut: RREQUEST: dutpost_bulk <-10.238.40.143/37088 h=390 d=16
Jul 11 16:11:52:213 [139681125603136] dut: data bulk_size=0
Jul 11 16:11:52:213 [139681125603136] dut: nimSockaddr2Ip - found 10.238.40.143
Jul 11 16:11:52:214 [139681125603136] dut: nimIP2Ether - new UDP socket fd=26
Jul 11 16:11:52:214 [139681125603136] dut: nimVerifyLogin dut
Jul 11 16:11:52:214 [139681125603136] dut: verify - [target] prid=dut cmd=dutpost_bulk ip=10.238.40.143 perm=2
Jul 11 16:11:52:214 [139679491933952] dut: nimSession:0x174a1e0:25:10.238.40.143/37088:10.238.40.143/37088 - needs cross-thread locking
Jul 11 16:11:52:214 [139679491933952] dut: SREPLY: status = 0(OK) ->10.238.40.143/37088
Jul 11 16:11:52:214 [139679491933952] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:52:214 [139679491933952] dut: data bulk_size_max=10000
Jul 11 16:11:52:225 [139681125603136] dut: RREQUEST: dutpost_bulk <-10.238.40.143/37088 h=390 d=72750
Jul 11 16:11:52:226 [139681125603136] dut: data bulk_size=100 bulk_list=PPDS(72695) qsize=263
Jul 11 16:11:52:229 [139679483541248] dut: SREPLY: status = 0(OK) ->10.238.40.143/37088
Jul 11 16:11:52:229 [139679483541248] dut: head mtype=200 status=0 seq=1
Jul 11 16:11:52:240 [139681125603136] dut: RREQUEST: dutpost_bulk <-10.238.40.143/37088 h=390 d=69890
Jul 11 16:11:52:240 [139681125603136] dut: data bulk_size=100 bulk_list=PPDS(69835) qsize=164
Jul 11 16:11:52:243 [139679491933952] dut: SREPLY: status = 0(OK) ->10.238.40.143/37088
Jul 11 16:11:52:243 [139679491933952] dut: head mtype=200 status=0 seq=2
Jul 11 16:11:52:243 [139679491933952] dut: data bulk_size_max=10000
Jul 11 16:11:52:254 [139681125603136] dut: RREQUEST: dutpost_bulk <-10.238.40.143/37088 h=390 d=44615
Jul 11 16:11:52:254 [139681125603136] dut: data bulk_size=64 bulk_list=PPDS(44561) qsize=64
Jul 11 16:11:52:256 [139679483541248] dut: SREPLY: status = 0(OK) ->10.238.40.143/37088
Jul 11 16:11:52:256 [139679483541248] dut: head mtype=200 status=0 seq=3
Jul 11 16:11:52:504 [139680305600256] dut: cfgReader file open: dut.cfg
Jul 11 16:11:52:504 [139680305600256] dut: cfgReader file close: dut.cfg
Jul 11 16:11:52:504 [139680305600256] dut: cfgReader file open: dut.cfg
Jul 11 16:11:52:505 [139680305600256] dut: cfgReader file close: dut.cfg
Jul 11 16:11:52:505 [139680305600256] dut: cfgReader file open: dut.cfg
Jul 11 16:11:52:505 [139680305600256] dut: cfgReader file close: dut.cfg
Jul 11 16:11:52:506 [139680297207552] dut: topology - main thread - worker thread pool started
Jul 11 16:11:52:721 [139681004775168] dut: RREQUEST: dutup <-10.238.42.217/39140 h=315 d=379
Jul 11 16:11:52:721 [139681004775168] dut: head mtype=100 cmd=dutup seq=0 ts=1499811114 frm=0.0.0.0/39140 tout=0 addr= sid=jU+GzsjC7tvUL8vyUhRLHAADMTQ5OTgxMTcxNAFHcmFlbWVQcmltYXJ5X2h1YgEx
Jul 11 16:11:52:721 [139681004775168] dut: dutup source: Primary_dut
Jul 11 16:11:52:721 [139681004775168] dut: MUTEX_LOCK? hash(dutinfo_update)
Jul 11 16:11:52:721 [139681004775168] dut: MUTEX_LOCK hash(dutinfo_update)
Jul 11 16:11:52:721 [139681004775168] dut: dutinfo_update - found dutinfo for /Primary_dom/Primary_dut
Jul 11 16:11:52:721 [139681004775168] dut: dutinfo_update - topology - origin was found in update - addr=/Primary_dom/Primary_dut/Primary/dut, from 10.238.42.217/39140
Jul 11 16:11:52:721 [139681004775168] dut: dutinfo_update - Primary_dom/Primary_dut from=10.238.42.217/39140 CHANGED proximity=0 status=0 secver=22
Jul 11 16:11:52:721 [139681004775168] dut: ch_dutlist /Primary_dom/Primary_dut/Primary/dut
Jul 11 16:11:52:721 [139681004775168] dut: MUTEX_UNLOCK? hash(dutinfo_update)
Jul 11 16:11:52:721 [139681004775168] dut: MUTEX_UNLOCK hash(dutinfo_update)
Jul 11 16:11:53:255 [139681125603136] dut: medium timeout
Jul 11 16:11:53:490 [139681125603136] dut: Device State: OFF
Jul 11 16:11:53:660 [139681125603136] dut: sockAccept: new socket fd=26
Jul 11 16:11:53:660 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x174c6c0 fd=26 10.238.40.228/48002<-10.238.40.232/56084
Jul 11 16:11:53:660 [139681125603136] dut: RREQUEST: nametoip <-10.238.40.232/56084 h=321 d=83
Jul 11 16:11:53:660 [139681125603136] dut: head mtype=100 cmd=nametoip seq=0 ts=1499811114 frm=10.238.40.232/56084 tout=10 addr= sid=FueJqQ3SMYAMEY38NQeKZgADMTQ5OTgxMTcwNAFheGEtdWltdW1wMS1kZXZfaHVi
Jul 11 16:11:53:660 [139681125603136] dut: MUTEX_LOCK? hash(inametoip)
Jul 11 16:11:53:660 [139681125603136] dut: MUTEX_LOCK hash(inametoip)
Jul 11 16:11:53:660 [139681125603136] dut: MUTEX_UNLOCK? hash(inametoip)
Jul 11 16:11:53:660 [139681125603136] dut: MUTEX_UNLOCK hash(inametoip)
Jul 11 16:11:53:660 [139681125603136] dut: SREPLY: status = 4(not found) ->10.238.40.232/56084
Jul 11 16:11:53:660 [139681125603136] dut: head mtype=200 status=4 seq=0
Jul 11 16:11:53:660 [139681125603136] dut: RREQUEST: _close <-10.238.40.232/56084 h=319 d=0
Jul 11 16:11:53:660 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811114 frm=10.238.40.232/56084 tout=10 addr= sid=FueJqQ3SMYAMEY38NQeKZgADMTQ5OTgxMTcwNAFheGEtdWltdW1wMS1kZXZfaHVi
Jul 11 16:11:53:660 [139681125603136] dut: sockClose:0x174c6c0:10.238.40.228/48002
Jul 11 16:11:53:723 [139681125603136] dut: sockAccept: new socket fd=26
Jul 11 16:11:53:723 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x17503d0 fd=26 10.238.40.228/48002<-10.238.40.228/37222
Jul 11 16:11:53:723 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37222
Jul 11 16:11:53:723 [139681125603136] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:53:723 [139681125603136] dut: RREQUEST: _close <-10.238.40.228/37222 h=108 d=0
Jul 11 16:11:53:723 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811113 frm=10.238.40.228/37222 tout=15 addr=
Jul 11 16:11:53:723 [139681125603136] dut: sockClose:0x17503d0:10.238.40.228/48002
Jul 11 16:11:53:724 [139681125603136] dut: sockAccept: new socket fd=26
Jul 11 16:11:53:724 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x17528b0 fd=26 10.238.40.228/48002<-10.238.40.228/37224
Jul 11 16:11:53:724 [139681125603136] dut: RREQUEST: login <-10.238.40.228/37224 h=108 d=250
Jul 11 16:11:53:724 [139681125603136] dut: head mtype=100 cmd=login seq=0 ts=1499811113 frm=10.238.40.228/37224 tout=180 addr=
Jul 11 16:11:53:724 [139681125603136] dut: data ip=10.238.40.228 ether=10.238.40.228 logindta=[crdta=HEX(160):9428a3edf4dcde9c49c2cb5e33258d66 crlen=151]
Jul 11 16:11:53:724 [139681125603136] dut: login from ctrl 10.238.40.228/37224
Jul 11 16:11:53:724 [139681125603136] dut: login - probe=controller permissions=read ip=10.238.40.228
Jul 11 16:11:53:724 [139681125603136] dut: Login: succeeded for controller, ip = 10.238.40.228
Jul 11 16:11:53:724 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37224
Jul 11 16:11:53:724 [139681125603136] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:53:724 [139681125603136] dut: data sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:725 [139681125603136] dut: RREQUEST: _close <-10.238.40.228/37224 h=109 d=0
Jul 11 16:11:53:725 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811113 frm=10.238.40.228/37224 tout=180 addr=
Jul 11 16:11:53:725 [139681125603136] dut: sockClose:0x17528b0:10.238.40.228/48002
Jul 11 16:11:53:725 [139681125603136] dut: sockAccept: new socket fd=26
Jul 11 16:11:53:725 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x1754d90 fd=26 10.238.40.228/48002<-10.238.40.228/37226
Jul 11 16:11:53:725 [139681125603136] dut: RREQUEST: _status <-10.238.40.228/37226 h=360 d=0
Jul 11 16:11:53:725 [139681125603136] dut: head mtype=100 cmd=_status seq=0 ts=1499811113 frm=10.238.40.228/37226 tout=15 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:725 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37226
Jul 11 16:11:53:725 [139681125603136] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:53:725 [139681125603136] dut: data name=dut company=CA version=7.92saas1 [Build 7.92saas1.1, Jul 11 2017] started=1499811111 restarted=0 connections=5 messages=1 libversion=6.01 (64bit) libdate=Jul 11 2017 ssl_mode=0 ssl_cipher=DEFAULT ssl_version=OpenSSL 1.0.2i 22 Sep 2016
Jul 11 16:11:53:726 [139681125603136] dut: RREQUEST: _close <-10.238.40.228/37226 h=359 d=0
Jul 11 16:11:53:726 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811113 frm=10.238.40.228/37226 tout=15 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:726 [139681125603136] dut: sockClose:0x1754d90:10.238.40.228/48002
Jul 11 16:11:53:726 [139681125603136] dut: sockAccept: new socket fd=26
Jul 11 16:11:53:726 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x1757270 fd=26 10.238.40.228/48002<-10.238.40.228/37228
Jul 11 16:11:53:748 [139681125603136] dut: RREQUEST: probelist <-10.238.40.228/37228 h=362 d=18749
Jul 11 16:11:53:748 [139681125603136] dut: head mtype=100 cmd=probelist seq=0 ts=1499811113 frm=10.238.40.228/37228 tout=0 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:748 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37228
Jul 11 16:11:53:748 [139681125603136] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:53:924 [139681125603136] dut: sockAccept: new socket fd=27
Jul 11 16:11:53:924 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x1759750 fd=27 10.238.40.228/48002<-10.238.40.228/37236
Jul 11 16:11:53:924 [139681125603136] dut: RREQUEST: verify_login <-10.238.40.228/37236 h=367 d=145
Jul 11 16:11:53:924 [139681125603136] dut: head mtype=100 cmd=verify_login seq=0 ts=1499811113 frm=10.238.40.228/37236 tout=180 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:924 [139681125603136] dut: data time=1499811113 cmd=port_list prid=controller access=1 ip=10.238.40.228 ether=0:50:56:9d:7d:16 ident=118729019
Jul 11 16:11:53:924 [139681125603136] dut: verify_login from ctrl 10.238.40.228/37236
Jul 11 16:11:53:924 [139681125603136] dut: verify - [target] prid=controller cmd=port_list ip=10.238.40.228 perm=1
Jul 11 16:11:53:924 [139681125603136] dut: SREPLY: status = 6(permission denied) ->10.238.40.228/37236
Jul 11 16:11:53:924 [139681125603136] dut: head mtype=200 status=6 seq=0
Jul 11 16:11:53:924 [139681125603136] dut: data time=1499811113 access=1 ident=118729019
Jul 11 16:11:53:925 [139681125603136] dut: RREQUEST: _close <-10.238.40.228/37236 h=360 d=0
Jul 11 16:11:53:925 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811113 frm=10.238.40.228/37236 tout=180 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:925 [139681125603136] dut: sockClose:0x1759750:10.238.40.228/48002
Jul 11 16:11:53:925 [139681125603136] dut: RREQUEST: login <-10.238.40.228/37228 h=357 d=253
Jul 11 16:11:53:925 [139681125603136] dut: head mtype=100 cmd=login seq=1 ts=1499811113 frm=10.238.40.228/37228 tout=0 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:925 [139681125603136] dut: data logindta=[crdta=HEX(160):9428a3edf4dcde9c49c2cb5e33258d66 crlen=150] ip=10.238.40.228 ether=0:50:56:9d:7d:16
Jul 11 16:11:53:925 [139681125603136] dut: login from ctrl 10.238.40.228/37228
Jul 11 16:11:53:925 [139681125603136] dut: login - probe=distsrv permissions=admin ip=10.238.40.228
Jul 11 16:11:53:925 [139681125603136] dut: Login: succeeded for distsrv, ip = 10.238.40.228
Jul 11 16:11:53:925 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37228
Jul 11 16:11:53:925 [139681125603136] dut: head mtype=200 status=0 seq=1
Jul 11 16:11:53:925 [139681125603136] dut: data sid=LArfduc52PJX4HJXNM+tSQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:925 [139681125603136] dut: sockAccept: new socket fd=27
Jul 11 16:11:53:925 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x1762710 fd=27 10.238.40.228/48002<-10.238.40.228/37240
Jul 11 16:11:53:925 [139681125603136] dut: RREQUEST: verify_login <-10.238.40.228/37240 h=367 d=396
Jul 11 16:11:53:925 [139681125603136] dut: head mtype=100 cmd=verify_login seq=0 ts=1499811113 frm=10.238.40.228/37240 tout=180 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:925 [139681125603136] dut: data time=1499811113 cmd=port_list prid=controller access=1 ip=10.238.40.228 ether=0:50:56:9d:7d:16 ident=118729019 sid=LArfduc52PJX4HJXNM+tSQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:925 [139681125603136] dut: verify_login from ctrl 10.238.40.228/37240
Jul 11 16:11:53:925 [139681125603136] dut: verify - [target] prid=controller cmd=port_list ip=10.238.40.228 perm=1
Jul 11 16:11:53:925 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37240
Jul 11 16:11:53:925 [139681125603136] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:53:925 [139681125603136] dut: data time=1499811113 access=1 ident=118729019
Jul 11 16:11:53:926 [139681125603136] dut: RREQUEST: _close <-10.238.40.228/37240 h=360 d=0
Jul 11 16:11:53:926 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811113 frm=10.238.40.228/37240 tout=180 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:53:926 [139681125603136] dut: sockClose:0x1762710:10.238.40.228/48002
Jul 11 16:11:54:661 [139681125603136] dut: sockAccept: new socket fd=27
Jul 11 16:11:54:661 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x1764bf0 fd=27 10.238.40.228/48002<-10.238.40.232/56088
Jul 11 16:11:54:661 [139681125603136] dut: RREQUEST: nametoip <-10.238.40.232/56088 h=321 d=83
Jul 11 16:11:54:661 [139681125603136] dut: head mtype=100 cmd=nametoip seq=0 ts=1499811115 frm=10.238.40.232/56088 tout=10 addr= sid=FueJqQ3SMYAMEY38NQeKZgADMTQ5OTgxMTcwNAFheGEtdWltdW1wMS1kZXZfaHVi
Jul 11 16:11:53:490 [139681125603136] dut: Device State: ON
Jul 11 16:11:54:661 [139681125603136] dut: MUTEX_LOCK? hash(inametoip)
Jul 11 16:11:54:661 [139681125603136] dut: MUTEX_LOCK hash(inametoip)
Jul 11 16:11:54:661 [139681125603136] dut: MUTEX_UNLOCK? hash(inametoip)
Jul 11 16:11:54:661 [139681125603136] dut: MUTEX_UNLOCK hash(inametoip)
Jul 11 16:11:54:661 [139681125603136] dut: SREPLY: status = 4(not found) ->10.238.40.232/56088
Jul 11 16:11:54:661 [139681125603136] dut: head mtype=200 status=4 seq=0
Jul 11 16:11:54:661 [139681125603136] dut: Device State: ERR
Jul 11 16:11:54:662 [139681125603136] dut: RREQUEST: _close <-10.238.40.232/56088 h=319 d=0
Jul 11 16:11:54:662 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811115 frm=10.238.40.232/56088 tout=10 addr= sid=FueJqQ3SMYAMEY38NQeKZgADMTQ5OTgxMTcwNAFheGEtdWltdW1wMS1kZXZfaHVi
Jul 11 16:11:54:662 [139681125603136] dut: sockClose:0x1764bf0:10.238.40.228/48002
Jul 11 16:11:55:733 [139681004775168] dut: RREQUEST: dutup <-10.238.40.49/57468 h=291 d=330
Jul 11 16:11:55:733 [139681004775168] dut: head mtype=100 cmd=dutup seq=0 ts=1499811117 frm=0.0.0.0/57468 tout=0 addr= sid=9GfWh1+qhQNZeoajtpQ8HgADMTQ5OTgxMTcxNwF0ZXN0Y2VudDcBMAExMC4yMzgu
Jul 11 16:11:55:733 [139681004775168] dut: dutup source: testcent7
Jul 11 16:11:55:733 [139681004775168] dut: MUTEX_LOCK? hash(dutinfo_update)
Jul 11 16:11:55:733 [139681004775168] dut: MUTEX_LOCK hash(dutinfo_update)
Jul 11 16:11:55:733 [139681004775168] dut: dutinfo_update - found dutinfo for /dom/testcent7
Jul 11 16:11:55:733 [139681004775168] dut: dutinfo_update - topology - origin was found in update - addr=/dom/testcent7/testcent7/dut, from 10.238.40.49/57468
Jul 11 16:11:55:733 [139681004775168] dut: dutinfo_update - dom/testcent7 from=10.238.40.49/57468 CHANGED proximity=0 status=0 secver=172
Jul 11 16:11:55:733 [139681004775168] dut: ch_dutlist /dom/testcent7/testcent7/dut
Jul 11 16:11:55:733 [139681004775168] dut: MUTEX_UNLOCK? hash(dutinfo_update)
Jul 11 16:11:55:733 [139681004775168] dut: MUTEX_UNLOCK hash(dutinfo_update)
Jul 11 16:11:56:067 [139681125603136] dut: data logindta=[crdta=HEX(144):9428a3edf4dcde9c49c2cb5e33258d66 crlen=135] ip=10.238.40.228 ether=0:50:56:9d:7d:16
Jul 11 16:11:56:067 [139681125603136] dut: login from ctrl 10.238.40.228/37228
Jul 11 16:11:56:067 [139681125603136] dut: login - probe=automated_deployment_engine permissions=admin ip=10.238.40.228
Jul 11 16:11:56:067 [139681125603136] dut: Login: succeeded for automated_deployment_engine, ip = 10.238.40.228
Jul 11 16:11:56:067 [139681125603136] dut: Device State: ERR
Jul 11 16:11:56:067 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37228
Jul 11 16:11:56:067 [139681125603136] dut: head mtype=200 status=0 seq=2
Jul 11 16:11:56:067 [139681125603136] dut: data sid=6HLrdYRrql15M84HvmtEEgADMTQ5OTgzMjcxNgFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:56:071 [139681125603136] dut: sockAccept: new socket fd=27
Jul 11 16:11:56:071 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x17670d0 fd=27 10.238.40.228/48002<-10.238.40.228/37268
Jul 11 16:11:56:071 [139681125603136] dut: RREQUEST: subscribe <-10.238.40.228/37268 h=178 d=83
Jul 11 16:11:56:071 [139681125603136] dut: data subject=AutomatedDeployment id=NimListenHandler heartbeat_interval=2
Jul 11 16:11:56:071 [139681125603136] dut: Subscribe request received from 10.238.40.228/37268
Jul 11 16:11:56:512 [139679475148544] dut: Processing new subscribe request from '10.238.40.228/37268'
Jul 11 16:11:56:512 [139679475148544] dut: ciOpen - cache path: /opt/nimsoft/niscache
Jul 11 16:11:56:512 [139679475148544] dut: ciOpen - initializing global CI cache
Jul 11 16:11:56:512 [139679475148544] dut: ciSaveMetric - saving MET [MC84D2BF98A3E711E125B9024C45F3B02] 10.1:10
Jul 11 16:11:56:512 [139679475148544] dut: internal alarm - Number of subscribers is below the threshold., 0, subs
Jul 11 16:11:56:512 [139679475148544] dut: ciClose - [C6346694FACBF1CB4ADEEA28D21E4BFAB]
Jul 11 16:11:56:512 [139679475148544] dut: add_subscriber id=NimListenHandler sub=0x7f09c8001200
Jul 11 16:11:56:512 [139679475148544] dut: subscription request header: Size=178
Jul 11 16:11:56:512 [139679475148544] dut: frm PDS_PCH 20 10.238.40.228/37268
Jul 11 16:11:56:512 [139679475148544] dut: mtype PDS_PCH 4 100
Jul 11 16:11:56:512 [139679475148544] dut: charset PDS_PCH 6 UTF-8
Jul 11 16:11:56:512 [139679475148544] dut: cmd PDS_PCH 10 subscribe
Jul 11 16:11:56:512 [139679475148544] dut: seq PDS_I 2 0
Jul 11 16:11:56:512 [139679475148544] dut: ts PDS_I 11 1499811116
Jul 11 16:11:56:512 [139679475148544] dut: subscription request data : Size=83
Jul 11 16:11:56:512 [139679475148544] dut: subject PDS_PCH 20 AutomatedDeployment
Jul 11 16:11:56:512 [139679475148544] dut: id PDS_PCH 17 NimListenHandler
Jul 11 16:11:56:512 [139679475148544] dut: heartbeat_interval PDS_I 2 2
Jul 11 16:11:56:512 [139679475148544] dut: Add subscriber to temporary queue 'AutomatedDeployment' (requested by '10.238.40.228/37268')
Jul 11 16:11:56:512 [139679475148544] dut: newRoute name=t_0 pr=0x7f09c8001830
Jul 11 16:11:56:512 [139679475148544] dut: TMP route 't_0' created for subject 'AutomatedDeployment'
Jul 11 16:11:56:512 [139679475148544] dut: subscriber did not request a reply_timeout, using default of 60
Jul 11 16:11:56:512 [139680565675776] dut: Queue management thread for 't_0' started
Jul 11 16:11:56:512 [139680565675776] dut: Queue 't_0' will start reading at file sequence no. 0
Jul 11 16:11:56:512 [139680565675776] dut: Queue 't_0' will start writing at file sequence no. 0
Jul 11 16:11:56:512 [139680565675776] dut: Queue 't_0' opened file '0.sds' for writing
Jul 11 16:11:56:512 [139680565675776] dut: Queue 't_0' now reading from file '0.sds' (contains 0 msgs, starting @ pos 0)
Jul 11 16:11:56:512 [139679475148544] dut: nimSession:0x17670d0:27:10.238.40.228/37268:10.238.40.228/37268 - needs cross-thread locking
Jul 11 16:11:56:513 [139679475148544] dut: SREPLY: status = 0(OK) ->10.238.40.228/37268
Jul 11 16:11:56:513 [139679475148544] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:56:513 [139679475148544] dut: data heartbeat_interval=2 reply_timeout=60
Jul 11 16:11:56:513 [139679475148544] dut: Subscriber 'NimListenHandler' at '10.238.40.228/37268' attached to queue 't_0' (subject:AutomatedDeployment requested bulk:0, granted bulk:0, minimum bulk:0, wait:0, heartbeat: 2, reply timeout: 60), time used: 0 ms
Jul 11 16:11:56:513 [139679475148544] dut: Subscriber 'NimListenHandler' attached to queue 't_0' sub=0x7f09c8001200 pr=0x7f09c8001830 nims=0x17670d0 sfd=27
Jul 11 16:11:56:514 [139679517112064] dut: Queue sender thread for 't_0' started
Jul 11 16:11:56:514 [139679517112064] dut: SREQUEST: heartbeat ->10.238.40.228/37268
Jul 11 16:11:56:514 [139679517112064] dut: head mtype=100 cmd=heartbeat seq=0 ts=1499811116 frm=10.238.40.228/48002 tout=10 addr= sid=lpW5VPKZ/DKdf80dKgf9jAADMTQ5OTgxMTE3MQFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:56:515 [139679517112064] dut: RREPLY: status=OK(0) <-10.238.40.228/37268 h=55 d=0
Jul 11 16:11:56:515 [139679517112064] dut: head mtype=200 charset=UTF-8 seq=0 status=0
Jul 11 16:11:56:515 [139679517112064] dut: Sent heartbeat on queue route 't_0'
Jul 11 16:11:57:291 [139681125603136] dut: RREQUEST: login <-10.238.40.228/37228 h=357 d=187
Jul 11 16:11:57:291 [139681125603136] dut: head mtype=100 cmd=login seq=3 ts=1499811117 frm=10.238.40.228/37228 tout=0 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:57:291 [139681125603136] dut: data logindta=[crdta=HEX(96):9428a3edf4dcde9c49c2cb5e33258d66 crlen=87] ip=10.238.40.228 ether=0:50:56:9d:7d:16
Jul 11 16:11:57:291 [139681125603136] dut: login from ctrl 10.238.40.228/37228
Jul 11 16:11:57:291 [139681125603136] dut: login - probe=mpse permissions=admin ip=10.238.40.228
Jul 11 16:11:57:291 [139681125603136] dut: Login: succeeded for mpse, ip = 10.238.40.228
Jul 11 16:11:57:291 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37228
Jul 11 16:11:57:291 [139681125603136] dut: head mtype=200 status=0 seq=3
Jul 11 16:11:57:291 [139681125603136] dut: data sid=5EvERBzKD/WAIQ2kdtmGOAADMTQ5OTgzMjcxNwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:57:303 [139681125603136] dut: sockAccept: new socket fd=30
Jul 11 16:11:57:303 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x17695b0 fd=30 10.238.40.228/48002<-10.238.40.228/37290
Jul 11 16:11:57:305 [139681125603136] dut: RREQUEST: license_info <-10.238.40.228/37290 h=364 d=0
Jul 11 16:11:57:305 [139681125603136] dut: nimSockaddr2Ip - found 10.238.40.228
Jul 11 16:11:57:305 [139681125603136] dut: nimIP2Ether - new UDP socket fd=31
Jul 11 16:11:57:305 [139681125603136] dut: nimVerifyLogin dut
Jul 11 16:11:57:305 [139681125603136] dut: verify - [target] prid=dut cmd=license_info ip=10.238.40.228 perm=1
Jul 11 16:11:57:305 [139681125603136] dut: license_info - from 10.238.40.228/37290
Jul 11 16:11:57:305 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37290
Jul 11 16:11:57:305 [139681125603136] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:57:305 [139681125603136] dut: Device State: OFF
Jul 11 16:11:57:305 [139681125603136] dut: RREQUEST: _close <-10.238.40.228/37290 h=357 d=0
Jul 11 16:11:57:305 [139681125603136] dut: sockClose:0x17695b0:10.238.40.228/48002
Jul 11 16:11:57:349 [139681125603136] dut: sockAccept: new socket fd=30
Jul 11 16:11:57:349 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x176ba90 fd=30 10.238.40.228/48002<-10.238.40.228/37306
Jul 11 16:11:57:349 [139681125603136] dut: RREQUEST: verify_login <-10.238.40.228/37306 h=367 d=318
Jul 11 16:11:57:349 [139681125603136] dut: head mtype=100 cmd=verify_login seq=0 ts=1499811117 frm=10.238.40.228/37306 tout=180 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:57:349 [139681125603136] dut: data time=1499811117 cmd=probe_list prid=controller access=1 ip=10.238.40.228 ether=0:50:56:9d:7d:16 ident=2122925495 sid=5EvERBzKD/WAIQ2kdtmGOAADMTQ5OTgzMjcxNwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:57:349 [139681125603136] dut: verify_login from ctrl 10.238.40.228/37306
Jul 11 16:11:57:349 [139681125603136] dut: verify - [target] prid=controller cmd=probe_list ip=10.238.40.228 perm=1
Jul 11 16:11:57:349 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37306
Jul 11 16:11:57:349 [139681125603136] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:57:349 [139681125603136] dut: data time=1499811117 access=1 ident=2122925495
Jul 11 16:11:57:350 [139681125603136] dut: RREQUEST: _close <-10.238.40.228/37306 h=360 d=0
Jul 11 16:11:57:350 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811117 frm=10.238.40.228/37306 tout=180 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:57:350 [139681125603136] dut: sockClose:0x176ba90:10.238.40.228/48002
Jul 11 16:11:58:327 [139679517112064] dut: SREQUEST: heartbeat ->10.238.40.228/37268
Jul 11 16:11:58:327 [139679517112064] dut: head mtype=100 cmd=heartbeat seq=1 ts=1499811118 frm=10.238.40.228/48002 tout=10 addr= sid=lpW5VPKZ/DKdf80dKgf9jAADMTQ5OTgxMTE3MQFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:58:328 [139679517112064] dut: RREPLY: status=OK(0) <-10.238.40.228/37268 h=55 d=0
Jul 11 16:11:58:328 [139679517112064] dut: head mtype=200 charset=UTF-8 seq=1 status=0
Jul 11 16:11:58:328 [139679517112064] dut: Sent heartbeat on queue route 't_0'
Jul 11 16:11:58:710 [139681125603136] dut: sockAccept: new socket fd=30
Jul 11 16:11:58:710 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x174c6c0 fd=30 10.238.40.228/48002<-172.17.60.11/49248
Jul 11 16:11:58:710 [139681125603136] dut: RREQUEST: subscribe <-172.17.60.11/49248 h=171 d=81
Jul 11 16:11:58:710 [139681125603136] dut: data subject=_$dutALL,alarm_stats id=Infrastructure Manager [administrator]
Jul 11 16:11:58:710 [139681125603136] dut: Device State: ON
Jul 11 16:11:58:710 [139681125603136] dut: Subscribe request received from 172.17.60.11/49248
Jul 11 16:11:58:962 [139681125603136] dut: sockAccept: new socket fd=31
Jul 11 16:11:58:962 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x1759750 fd=31 10.238.40.228/48002<-10.238.40.228/37400
Jul 11 16:11:58:962 [139681125603136] dut: RREQUEST: verify_login <-10.238.40.228/37400 h=367 d=147
Jul 11 16:11:58:962 [139681125603136] dut: head mtype=100 cmd=verify_login seq=0 ts=1499811118 frm=10.238.40.228/37400 tout=180 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:58:962 [139681125603136] dut: data time=1499811118 cmd=probe_list prid=controller access=1 ip=10.238.40.228 ether=0:50:56:9d:7d:16 ident=1824950816
Jul 11 16:11:58:962 [139681125603136] dut: verify_login from ctrl 10.238.40.228/37400
Jul 11 16:11:58:962 [139681125603136] dut: verify - [target] prid=controller cmd=probe_list ip=10.238.40.228 perm=1
Jul 11 16:11:58:962 [139681125603136] dut: SREPLY: status = 6(permission denied) ->10.238.40.228/37400
Jul 11 16:11:58:962 [139681125603136] dut: head mtype=200 status=6 seq=0
Jul 11 16:11:58:962 [139681125603136] dut: data time=1499811118 access=1 ident=1824950816
Jul 11 16:11:58:962 [139681125603136] dut: RREQUEST: _close <-10.238.40.228/37400 h=360 d=0
Jul 11 16:11:58:962 [139681125603136] dut: head mtype=100 cmd=_close seq=1 ts=1499811118 frm=10.238.40.228/37400 tout=180 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:58:962 [139681125603136] dut: sockClose:0x1759750:10.238.40.228/48002
Jul 11 16:11:59:015 [139681125603136] dut: RREQUEST: login <-10.238.40.228/37228 h=357 d=187
Jul 11 16:11:59:015 [139681125603136] dut: head mtype=100 cmd=login seq=4 ts=1499811119 frm=10.238.40.228/37228 tout=0 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:59:015 [139681125603136] dut: data logindta=[crdta=HEX(96):9428a3edf4dcde9c49c2cb5e33258d66 crlen=85] ip=10.238.40.228 ether=0:50:56:9d:7d:16
Jul 11 16:11:59:015 [139681125603136] dut: login from ctrl 10.238.40.228/37228
Jul 11 16:11:59:015 [139681125603136] dut: login - probe=ppm permissions=admin ip=10.238.40.228
Jul 11 16:11:59:015 [139681125603136] dut: Login: succeeded for ppm, ip = 10.238.40.228
Jul 11 16:11:59:015 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37228
Jul 11 16:11:59:015 [139681125603136] dut: head mtype=200 status=0 seq=4
Jul 11 16:11:59:015 [139681125603136] dut: data sid=kgFRn+RGLMX7RDgFkOaQ6gADMTQ5OTgzMjcxOQFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:59:048 [139681125603136] dut: RREQUEST: login <-10.238.40.228/37228 h=357 d=205
Jul 11 16:11:59:048 [139681125603136] dut: head mtype=100 cmd=login seq=5 ts=1499811119 frm=10.238.40.228/37228 tout=0 addr= sid=zYyeCp56Cg4og2P41oP7yQADMTQ5OTgzMjcxMwFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:59:048 [139681125603136] dut: data logindta=[crdta=HEX(112):9428a3edf4dcde9c49c2cb5e33258d66 crlen=111] ip=10.238.40.228 ether=0:50:56:9d:7d:16
Jul 11 16:11:59:048 [139681125603136] dut: login from ctrl 10.238.40.228/37228
Jul 11 16:11:59:048 [139681125603136] dut: login - probe=baseline_engine permissions=admin ip=10.238.40.228
Jul 11 16:11:59:048 [139681125603136] dut: Login: succeeded for baseline_engine, ip = 10.238.40.228
Jul 11 16:11:59:048 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37228
Jul 11 16:11:59:048 [139681125603136] dut: head mtype=200 status=0 seq=5
Jul 11 16:11:59:048 [139681125603136] dut: data sid=zW2CLPVTY5Vh1N4qgjwZZwADMTQ5OTgzMjcxOQFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:59:083 [139681125603136] dut: sockAccept: new socket fd=31
Jul 11 16:11:59:083 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x1762710 fd=31 10.238.40.228/48002<-10.238.40.228/37434
Jul 11 16:11:59:083 [139681125603136] dut: RREQUEST: queue_delete <-10.238.40.228/37434 h=368 d=62
Jul 11 16:11:59:083 [139681125603136] dut: nimSockaddr2Ip - found 10.238.40.228
Jul 11 16:11:59:083 [139681125603136] dut: nimIP2Ether - new UDP socket fd=32
Jul 11 16:11:59:083 [139681125603136] dut: nimVerifyLogin dut
Jul 11 16:11:59:083 [139681125603136] dut: verify - [target] prid=dut cmd=queue_delete ip=10.238.40.228 perm=3
Jul 11 16:11:59:083 [139681125603136] dut: Delete queue request received from 10.238.40.228/37434
Jul 11 16:11:59:100 [139681125603136] dut: sockAccept: new socket fd=32
Jul 11 16:11:59:100 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x1764bf0 fd=32 10.238.40.228/48002<-10.238.40.228/37438
Jul 11 16:11:59:100 [139681125603136] dut: RREQUEST: queue_list <-10.238.40.228/37438 h=366 d=0
Jul 11 16:11:59:100 [139681125603136] dut: nimSockaddr2Ip - found 10.238.40.228
Jul 11 16:11:59:100 [139681125603136] dut: nimIP2Ether - new UDP socket fd=33
Jul 11 16:11:59:100 [139681125603136] dut: nimVerifyLogin dut
Jul 11 16:11:59:100 [139681125603136] dut: verify - [target] prid=dut cmd=queue_list ip=10.238.40.228 perm=1
Jul 11 16:11:59:100 [139681125603136] dut: cfgReader file open: dut.cfg
Jul 11 16:11:59:100 [139681125603136] dut: cfgReader file close: dut.cfg
Jul 11 16:11:59:101 [139681125603136] dut: SREPLY: status = 0(OK) ->10.238.40.228/37438
Jul 11 16:11:59:101 [139681125603136] dut: head mtype=200 status=0 seq=0
Jul 11 16:11:59:101 [139681125603136] dut: data __file=dut.cfg sections=PPDS(2926)
Jul 11 16:11:59:101 [139681125603136] dut: RREQUEST: _close <-10.238.40.228/37438 h=361 d=0
Jul 11 16:11:59:101 [139681125603136] dut: sockClose:0x1764bf0:10.238.40.228/48002
Jul 11 16:11:59:102 [139681125603136] dut: sockAccept: new socket fd=32
Jul 11 16:11:59:102 [139681125603136] dut: sockAccept: new session nims=0x17279e0 new=0x17503d0 fd=32 10.238.40.228/48002<-10.238.40.228/37440
Jul 11 16:11:59:105 [139681125603136] dut: RREQUEST: subscribe <-10.238.40.228/37440 h=267 d=112
Jul 11 16:11:59:105 [139681125603136] dut: head mtype=100 charset=UTF-8 cmd=subscribe seq=0 ts=1499811119 sid=zW2CLPVTY5Vh1N4qgjwZZwADMTQ5OTgzMjcxOQFheGEtdWltc2VydmVyMS1kZXZf
Jul 11 16:11:59:105 [139681125603136] dut: data bulk_size=1000 attach=baseline_engine.BASELINE_CONFIG id=baseline_engine heartbeat_interval=5
Jul 11 16:11:59:105 [139681125603136] dut: Subscribe request received from 10.238.40.228/37440
Jul 11 16:11:59:201 [139681125603136] dut: Device State: OFF
Jul 11 16:11:59:522 [139679475148544] dut: Processing new subscribe request from '172.17.60.11/49248'
Jul 11 16:11:59:522 [139679475148544] dut: add_subscriber id=Infrastructure Manager [administrator] sub=0x7f09c8002020
# Python / Sqlite /SqlAlchemy article
# Python / SQLite /SQLAlchemy article
This repository contains the content and example code
for the python/sqlite/sqlaclchemy article I'm writing
This repository contains the content and example code
for the Python / SQLite / SQLAlchemy article I'm writing
for Real Python.
This project was built using Python 3.8.0
## Python Virtualenv
I use the `pyenv` tool to install Python versions on my Mac. I find it a very useful tool, and the instructions that follow use it, and are based on having Python version 3.8.0 installed using the following command:
```shell
$ pyenv install 3.8.0
```
## Installing The Project
From the main folder take the following steps:
From the main folder take the following steps (on a Mac):
* Install a Python virtual environment for this project
* `pyenv local 3.8.0`
* `python -m venv .venv`
* Activate the virtual environment
* `source .venv/bin/activate`
* Install the project:
```shell script
python -m pip install -e .
```
\ No newline at end of file
* `python -m pip install -e .`
# Build Files Used By The Examples
The code in this directory builds the various data files used
by the example programs. There are three build programs:
by the example programs. There is one build program:
* build_author_book_publisher_sqlite.py
* build_temp_data_csv.py
* build_temp_data_sqlite.py
* build_author_book_publisher_sqlite.py
## Build the Temperature CSV File
The build_temp_data_csv.py file builds a CSV data file
(temp_data.csv) in the data directory
containing temperature samples taken by students in a class.
The top row contains the labels, the students name followed
by a date value for each Wednesday of the week for a year.
It then creates data for each sample based on a table of
temperature data, +/- 10 to make the data look variable
and reasonable.
## Build the Temperature Database File
The build_temp_data_sqlite.py file builds a Sqlite database
from the previously created temp_data.csv file called
temp_data.db in the data directory.
## Build the Author / Book / Publisher Database File
The build_author_book_publisher_sqlite.py file builds
a database from the data/author_book_publisher.csv file.
This database contains the tables necessary to describe
the data and the relationships between the data necessary
for the examples.
The build_author_book_publisher_sqlite.py file builds
a database from the `data/author_book_publisher.csv` file.
This database contains the rows of comma delimited text to describe
the data and the relationships between the data necessary
for the examples.
## Directory Structure
The directory structure is set up in such a way the
build programs (as well as the examples) can find the
data files needed for each one.
The directory structure is set up in such a way the
build programs (as well as the examples) can find the
data files needed for each one.
## Executing the Programs
* Activate your Python virtualenv
* cd into the build/code directory
* python build_temp_data_csv.py - builds the csv data file
* python build_temp_data_sqlite.py - builds the temperature data from the csv file
* python build_author_book_publisher_sqlite.py - builds the author_book_publisher.db database file
Follow these steps to build the `data/author_book_publisher.db` database file.
* Activate your Python virtualenv
* cd into the build/code directory
* python build_author_book_publisher_sqlite.py - builds the author_book_publisher.db database file
......
......@@ -5,7 +5,7 @@ author_book_publisher.csv file.
import os
import csv
from pkg_resources import resource_filename
from importlib import resources
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from project.modules.models import Base
......@@ -30,11 +30,13 @@ def populate_database(session, author_book_publisher_data):
author = (
session.query(Author)
.filter(Author.lname == row["lname"])
.filter(Author.last_name == row["last_name"])
.one_or_none()
)
if author is None:
author = Author(fname=row["fname"], lname=row["lname"])
author = Author(
first_name=row["first_name"], last_name=row["last_name"]
)
session.add(author)
book = (
......@@ -69,19 +71,19 @@ def main():
print("starting")
# get the author/book/publisher data into a dictionary structure
csv_filepath = resource_filename(
with resources.path(
"project.data", "author_book_publisher.csv"
)
author_book_publisher_data = get_author_book_publisher_data(csv_filepath)
) as csv_filepath:
data = get_author_book_publisher_data(csv_filepath)
author_book_publisher_data = data
# get the filepath to the database file
sqlite_filepath = resource_filename(
with resources.path(
"project.data", "author_book_publisher.db"
)
# does the database exist?
if os.path.exists(sqlite_filepath):
os.remove(sqlite_filepath)
) as sqlite_filepath:
# does the database exist?
if os.path.exists(sqlite_filepath):
os.remove(sqlite_filepath)
# create the database
engine = create_engine(f"sqlite:///{sqlite_filepath}")
......
import csv
import datetime
from random import randint
from pkg_resources import resource_filename
start_date = datetime.datetime.strptime("2019-01-02", "%Y-%m-%d")
students = [
"John",
"Mary",
"Susan",
"Doug",
"Andrew",
"George",
"Martha",
"Paul",
"Helen",
]
temperature_data = [
10,
12,
16,
23,
13,
12,
14,
22,
25,
28,
32,
33,
37,
36,
35,
40,
44,
45,
50,
52,
58,
60,
66,
70,
70,
72,
78,
80,
81,
82,
85,
88,
90,
87,
90,
85,
82,
81,
78,
75,
72,
72,
70,
63,
65,
62,
60,
45,
40,
37,
30,
28,
]
def offset_temp(temperature):
"""
This function modifies the temperature +/- a random
amount up to 10
:param temperature: temperature to modify
:return: modified temperature
"""
return temperature + randint(-10, 10)
def main():
# create the CSV file
csv_filepath = resource_filename("project.data", "temp_data.csv")
with open(csv_filepath, "w") as data_fh:
# create the writer
csv_writer = csv.writer(data_fh)
# write the header
header = ["name"]
for week in range(0, 52):
current_date = start_date + datetime.timedelta(days=week * 7)
header.append(current_date.strftime("%Y-%m-%d"))
csv_writer.writerow(header)
# iterate through the students and write their data
for student in students:
data = [student]
# iterate through the weeks
for week in range(0, 52):
data.append(offset_temp(temperature_data[week]))
csv_writer.writerow(data)
if __name__ == "__main__":
main()
"""
This program gathers information from the temp_data.db file about temperature
"""
import os
import csv
from pkg_resources import resource_filename
from datetime import datetime
from sqlalchemy import create_engine
from sqlalchemy import Column, Integer, String, Date, Float
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class TemperatureData(Base):
__tablename__ = "temperature_data"
temperature_data_id = Column(Integer, primary_key=True)
name = Column(String, nullable=False)
date = Column(Date, nullable=False)
value = Column(Float, nullable=False)
def get_temperature_data(filepath):
"""
This function gets the temperature data from the csv file
"""
with open(filepath) as csvfile:
csv_reader = csv.DictReader(csvfile)
data = {row["name"]: row for row in csv_reader}
for value in data.values():
value.pop("name")
return data
def populate_database(session, temperature_data):
# insert the data
for student, data in temperature_data.items():
for date, value in data.items():
temp_data = TemperatureData(
name=student,
date=datetime.strptime(date, "%Y-%m-%d").date(),
value=value,
)
session.add(temp_data)
session.commit()
session.close()
def main():
print("starting")
# get the temperature data into a dictionary structure
csv_filepath = resource_filename("project.data", "temp_data.csv")
temperature_data = get_temperature_data(csv_filepath)
# get the filepath to the database file
sqlite_filepath = resource_filename("project.data", "temp_data.db")
# does the database exist?
if os.path.exists(sqlite_filepath):
os.remove(sqlite_filepath)
# create and populate the sqlite database
engine = create_engine(f"sqlite:///{sqlite_filepath}")
Base.metadata.create_all(engine)
Session = sessionmaker()
Session.configure(bind=engine)
session = Session()
populate_database(session, temperature_data)
print("finished")
if __name__ == "__main__":
main()
fname,lname,title,publisher
Issac,Asimov,Foundation,Random House
first_name,last_name,title,publisher
Isaac,Asimov,Foundation,Random House
Pearl,Buck,The Good Earth,Random House
Pearl,Buck,The Good Earth,Simon & Schuster
Tom,Clancy,The Hunt For Red October,Berkley
......@@ -7,7 +7,7 @@ Tom,Clancy,Patriot Games,Simon & Schuster
Stephen,King,It,Random House
Stephen,King,It,Penguin Random House
Stephen,King,Dead Zone,Random House
Stephen,King,The Shinning,Penguin Random House
Stephen,King,The Shining,Penguin Random House
John,Le Carre,"Tinker, Tailor, Solider, Spy: A George Smiley Novel",Berkley
Alex,Michaelides,The Silent Patient,Simon & Schuster
Carol,Shaben,Into The Abyss,Simon & Schuster
name,2019-01-02,2019-01-09,2019-01-16,2019-01-23,2019-01-30,2019-02-06,2019-02-13,2019-02-20,2019-02-27,2019-03-06,2019-03-13,2019-03-20,2019-03-27,2019-04-03,2019-04-10,2019-04-17,2019-04-24,2019-05-01,2019-05-08,2019-05-15,2019-05-22,2019-05-29,2019-06-05,2019-06-12,2019-06-19,2019-06-26,2019-07-03,2019-07-10,2019-07-17,2019-07-24,2019-07-31,2019-08-07,2019-08-14,2019-08-21,2019-08-28,2019-09-04,2019-09-11,2019-09-18,2019-09-25,2019-10-02,2019-10-09,2019-10-16,2019-10-23,2019-10-30,2019-11-06,2019-11-13,2019-11-20,2019-11-27,2019-12-04,2019-12-11,2019-12-18,2019-12-25
John,11,9,19,28,11,10,20,24,18,32,40,33,46,42,27,32,42,54,50,47,63,57,60,67,62,64,70,88,73,78,93,89,89,96,98,79,90,85,78,79,66,67,75,63,70,63,59,45,44,29,39,19
Mary,20,21,25,32,14,11,11,20,31,22,24,33,28,32,43,50,37,51,42,48,56,67,76,67,66,74,88,86,91,86,85,88,100,84,82,78,73,76,84,82,70,73,77,71,70,58,56,53,40,41,39,31
Susan,6,10,26,21,23,3,13,28,29,33,31,39,31,28,38,48,50,46,41,51,62,62,62,69,77,77,72,82,83,72,79,78,96,87,88,91,75,88,84,73,77,68,78,59,68,66,57,55,48,40,33,36
Doug,3,11,11,26,8,4,18,27,25,21,42,24,35,28,42,38,52,39,60,62,55,59,72,74,63,65,75,82,83,73,84,92,82,93,100,90,92,73,68,71,62,65,62,64,66,68,56,46,31,35,39,19
Andrew,12,21,8,17,12,16,23,12,19,32,27,42,34,44,35,47,45,54,55,60,56,56,62,71,72,62,72,80,85,86,91,98,80,88,84,92,89,88,71,78,63,79,68,67,62,57,54,44,39,30,36,23
George,18,4,19,31,22,2,7,26,34,25,36,38,36,35,34,38,42,55,48,46,60,60,68,62,65,62,87,73,82,77,82,97,97,80,95,92,73,74,79,78,81,82,63,71,74,57,57,38,38,32,25,21
Martha,14,12,6,20,10,12,7,26,32,25,41,31,30,38,42,37,50,47,56,51,58,70,74,63,70,76,73,89,77,82,77,80,88,81,81,77,89,73,87,74,77,72,62,61,57,67,56,46,40,32,25,34
Paul,18,22,12,32,5,8,15,29,16,27,24,25,27,37,37,42,42,36,49,54,59,56,65,62,76,63,83,72,75,89,79,85,97,82,100,76,73,73,81,67,74,73,61,53,59,66,64,44,42,42,25,34
Helen,14,6,13,18,20,11,12,16,31,19,34,41,44,46,39,50,39,38,50,48,51,61,56,73,78,73,73,90,86,90,82,97,100,90,92,80,73,79,72,82,62,76,72,72,68,56,69,52,41,40,37,36
# Example 1
This example uses the raw temp_data.csv file
to get data into the program and run
various Python functions on it.
In particular getting the average temperature
for a date across all the samples, and getting the
average temperature for every week for the entire
year and returning it sorted.
\ No newline at end of file
"""
This program gathers information from the temp_data.csv file about temperature
This is the example 1 program file
This example program was kindly created by Geir Arne Hjelle,
another RealPython author, as part of the editorial process
to improve this article and the information it presents.
You can learn more about Geir from this URL:
https://realpython.com/team/gahjelle/
"""
import csv
from pkg_resources import resource_filename
from datetime import datetime
from datetime import timedelta
from typing import List, Dict
from collections import defaultdict
from importlib import resources
import pandas as pd
from treelib import Tree
def get_temperature_data(filepath: str) -> Dict:
"""
This function gets the temperature data from the csv file
"""
with open(filepath) as csvfile:
csv_reader = csv.DictReader(csvfile)
data = {row["name"]: row for row in csv_reader}
for value in data.values():
value.pop("name")
return data
def get_data(filepath):
"""Get book data from the csv file"""
return pd.read_csv(filepath)
def get_average_temp_by_date(
date_string: str, temperature_data: Dict
) -> float:
"""
This function gets the average temperature for all the samples
taken by the students by date
:param date_string: date to find average temperature for
:param connection: database connection
:return: average temp for date, or None if not found
"""
# Target date
target_date = datetime.strptime(date_string, "%Y-%m-%d").date()
# Iterate through the data and get the data
data = []
for samples in temperature_data.values():
def get_books_by_publisher(data, ascending=True):
"""Returns the books by each publisher as a pandas series
# Iterate through the samples
for sample_date, sample in samples.items():
Args:
data: The pandas dataframe to get the from
ascending: The sorting direction for the returned data.
Defaults to True.
# Generate a date range for the sample
min_date = datetime.strptime(
sample_date, "%Y-%m-%d"
).date() + timedelta(days=-3)
max_date = datetime.strptime(
sample_date, "%Y-%m-%d"
).date() + timedelta(days=3)
if min_date <= target_date <= max_date:
data.append(float(sample))
Returns:
The sorted data as a pandas series
"""
return data.groupby("publisher").size().sort_values(ascending=ascending)
# Get the average temp
return sum(data) / len(data)
def get_authors_by_publisher(data, ascending=True):
"""Returns the authors by each publisher as a pandas series
def get_average_temp_sorted(direction: str, temperature_data: Dict) -> List:
dir = direction.lower()
if dir not in ["asc", "desc"]:
raise Exception(f"Unknown direction: {direction}")
Args:
data: The pandas dataframe to get the data from
ascending: The sorting direction for the returned data.
Defaults to True.
results = defaultdict(int)
for data in temperature_data.values():
for date, value in data.items():
results[date] += float(value)
Returns:
The sorted data as a pandas series
"""
return (
data.assign(name=data.first_name.str.cat(data.last_name, sep=" "))
.groupby("publisher")
.nunique()
.loc[:, "name"]
.sort_values(ascending=ascending)
)
for date, total in results.items():
results[date] = float(total) / float(len(temperature_data.keys()))
# Convert dictionary to list
results = results.items()
def add_new_book(data, author_name, book_title, publisher_name):
"""Adds a new book to the system"""
# Sort the list in the appropriate order
return sorted(
results, key=lambda v: v[1], reverse=False if dir == "asc" else True
# Does the book exist?
first_name, _, last_name = author_name.partition(" ")
if any(
(data.first_name == first_name)
& (data.last_name == last_name)
& (data.title == book_title)
& (data.publisher == publisher_name)
):
return data
# Add the new book
return data.append(
{
"first_name": first_name,
"last_name": last_name,
"title": book_title,
"publisher": publisher_name,
},
ignore_index=True,
)
def main():
print("starting")
def output_author_hierarchy(data):
"""Output the data as a hierarchy list of authors"""
authors = data.assign(
name=data.first_name.str.cat(data.last_name, sep=" ")
)
authors_tree = Tree()
authors_tree.create_node("Authors", "authors")
for author, books in authors.groupby("name"):
authors_tree.create_node(author, author, parent="authors")
for book, publishers in books.groupby("title")["publisher"]:
book_id = f"{author}:{book}"
authors_tree.create_node(book, book_id, parent=author)
for publisher in publishers:
authors_tree.create_node(publisher, parent=book_id)
# Get the temperature data into a dictionary structure
filepath = resource_filename("project.data", "temp_data.csv")
temperature_data = get_temperature_data(filepath)
# Output the hierarchical authors data
authors_tree.show()
# Get the average temperature by date
date_string = "2019-02-10"
average_temp = get_average_temp_by_date(date_string, temperature_data)
print(f"Average temp {date_string}: {average_temp:.2f}")
def main():
"""The main entry point of the program"""
# Get the resources for the program
with resources.path(
"project.data", "author_book_publisher.csv"
) as filepath:
data = get_data(filepath)
# Get the number of books printed by each publisher
books_by_publisher = get_books_by_publisher(data, ascending=False)
for publisher, total_books in books_by_publisher.items():
print(f"Publisher: {publisher}, total books: {total_books}")
print()
# Get the average temps for the year sorted ascending or descending
average_temps = get_average_temp_sorted("asc", temperature_data)
for date, average_temp in average_temps:
print(f"Date: {date}, average temp: {average_temp:.2f}")
# Get the number of authors each publisher publishes
authors_by_publisher = get_authors_by_publisher(data, ascending=False)
for publisher, total_authors in authors_by_publisher.items():
print(f"Publisher: {publisher}, total authors: {total_authors}")
print()
print("finished")
# Output hierarchical authors data
output_author_hierarchy(data)
# Add a new book to the data structure
data = add_new_book(
data,
author_name="Stephen King",
book_title="The Stand",
publisher_name="Random House",
)
# Output the updated hierarchical authors data
output_author_hierarchy(data)
if __name__ == "__main__":
......
# Example 2
This example uses temp_data.db database
file to get data into the program and run
various functions on it that use Sqlite SQL
to access the data.
In particular getting the average temperature
for a date across all the samples, and getting the
average temperature for every week for the entire
year and returning it sorted.
\ No newline at end of file
"""
This program gathers information from the database file about temperature
This program gathers information from the author_book_publisher.db
SQLite database file
"""
from pkg_resources import resource_filename
from datetime import datetime
from datetime import timedelta
import sqlite3
from importlib import resources
from sqlalchemy import and_, create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.sql import asc, desc, func
def get_average_temp_by_date(date_string, connection):
"""
This function gets the average temperature for all the samples
taken by the students by date
from project.modules.models import Author, Book, Publisher
from treelib import Tree
:param date_string: date to find average temperature for
:param connection: database connection
:return: average temp for date, or None if not found
"""
# Target date
target_date = datetime.strptime(date_string, "%Y-%m-%d").date()
min_date = target_date + timedelta(days=-3)
max_date = target_date + timedelta(days=3)
cursor = connection.cursor()
sql = """
SELECT
avg(value) as average
FROM temperature_data
WHERE date between ? and ?
def get_books_by_publishers(session, ascending=True):
"""Get a list of publishers and the number of books they've published
Args:
session: database session to use
ascending: direction to sort the results
Returns:
List: list of publisher sorted by number of books published
"""
result = cursor.execute(sql, (min_date, max_date)).fetchone()
return result[0] if result else None
if not isinstance(ascending, bool):
raise ValueError(f"Sorting value invalid: {ascending}")
direction = asc if ascending else desc
def get_average_temp_sorted(direction: str, connection) -> list:
return (
session.query(
Publisher.name, func.count(Book.title).label("total_books")
)
.join(Publisher.books)
.group_by(Publisher.name)
.order_by(direction("total_books"))
)
dir = direction.lower()
if dir not in ["asc", "desc"]:
raise Exception(f"Unknown direction: {direction}")
cursor = connection.cursor()
sql = f"""
SELECT
date,
AVG(value) as average_temp
FROM temperature_data
GROUP BY date
ORDER BY average_temp {dir}
"""
results = cursor.execute(sql).fetchall()
return results
def get_authors_by_publishers(session, ascending=True):
"""Get a list of publishers and the number of authors they've published
Args:
session: database session to use
ascending: direction to sort the results
def main():
print("starting")
Returns:
List: list of publisher sorted by number of authors published
"""
if not isinstance(ascending, bool):
raise ValueError(f"Sorting value invalid: {ascending}")
direction = asc if ascending else desc
return (
session.query(
Publisher.name,
func.count(Author.first_name).label("total_authors"),
)
.join(Publisher.authors)
.group_by(Publisher.name)
.order_by(direction("total_authors"))
)
def get_authors(session):
"""Get a list of author objects sorted by last name"""
return session.query(Author).order_by(Author.last_name).all()
def add_new_book(session, author_name, book_title, publisher_name):
"""Adds a new book to the system"""
# Get the author's first and last names
first_name, _, last_name = author_name.partition(" ")
# Check if the book exists
book = (
session.query(Book)
.join(Author)
.filter(Book.title == book_title)
.filter(
and_(
Author.first_name == first_name, Author.last_name == last_name
)
)
.filter(Book.publishers.any(Publisher.name == publisher_name))
.one_or_none()
)
# Does the book by the author and publisher already exist?
if book is not None:
return
# Check if the book exists for the author
book = (
session.query(Book)
.join(Author)
.filter(Book.title == book_title)
.filter(
and_(
Author.first_name == first_name, Author.last_name == last_name
)
)
.one_or_none()
)
# Create the new book if needed
if book is None:
book = Book(title=book_title)
# Get the author
author = (
session.query(Author)
.filter(
and_(
Author.first_name == first_name, Author.last_name == last_name
)
)
.one_or_none()
)
# Do we need to create the author?
if author is None:
author = Author(first_name=first_name, last_name=last_name)
session.add(author)
# Get the publisher
publisher = (
session.query(Publisher)
.filter(Publisher.name == publisher_name)
.one_or_none()
)
# Do we need to create the publisher?
if publisher is None:
publisher = Publisher(name=publisher_name)
session.add(publisher)
# Initialize the book relationships
book.author = author
book.publishers.append(publisher)
session.add(book)
# Commit to the database
session.commit()
def output_author_hierarchy(authors):
"""
Outputs the author/book/publisher information in
a hierarchical manner
:param authors: the collection of root author objects
:return: None
"""
authors_tree = Tree()
authors_tree.create_node("Authors", "authors")
for author in authors:
author_id = f"{author.first_name} {author.last_name}"
authors_tree.create_node(author_id, author_id, parent="authors")
for book in author.books:
book_id = f"{author_id}:{book.title}"
authors_tree.create_node(book.title, book_id, parent=author_id)
for publisher in book.publishers:
authors_tree.create_node(publisher.name, parent=book_id)
# Output the hierarchical authors data
authors_tree.show()
# Connect to the sqlite database
sqlite_filepath = resource_filename("project.data", "temp_data.db")
connection = sqlite3.connect(sqlite_filepath)
# Get the average temperature by date
date_string = "2019-02-10"
average_temp = get_average_temp_by_date(date_string, connection)
print(f"Average temp {date_string}: {average_temp:.2f}")
def main():
"""Main entry point of program"""
# Connect to the database using SQLAlchemy
with resources.path(
"project.data", "author_book_publisher.db"
) as sqlite_filepath:
engine = create_engine(f"sqlite:///{sqlite_filepath}")
Session = sessionmaker()
Session.configure(bind=engine)
session = Session()
# Get the number of books printed by each publisher
books_by_publisher = get_books_by_publishers(session, ascending=False)
for row in books_by_publisher:
print(f"Publisher: {row.name}, total books: {row.total_books}")
print()
# Get the average temps for the year sorted ascending or descending
average_temps = get_average_temp_sorted("asc", connection)
for date, average_temp in average_temps:
print(f"Date: {date}, average temp: {average_temp:.2f}")
# Get the number of authors each publisher publishes
authors_by_publisher = get_authors_by_publishers(session)
for row in authors_by_publisher:
print(f"Publisher: {row.name}, total authors: {row.total_authors}")
print()
print("finished")
# Output hierarchical authors data
authors = get_authors(session)
output_author_hierarchy(authors)
# Add a new book
add_new_book(
session,
author_name="Stephen King",
book_title="The Stand",
publisher_name="Random House",
)
# Output the updated hierarchical authors data
authors = get_authors(session)
output_author_hierarchy(authors)
if __name__ == "__main__":
......
# Example 3
This example uses SqlAlchemy to access the temp_data.db
database to get data into the program and run
various SqlAlchemy object methods to get the data.
In particular getting the average temperature
for a date across all the samples, and getting a list
of all the average temps for the year in sorted order.
\ No newline at end of file
from flask import Flask
from flask import render_template
from flask_bootstrap import Bootstrap
from flask_sqlalchemy import SQLAlchemy
from config import Config
# Define the application
app = Flask(__name__, instance_relative_config=False)
# Configure the application
app.config.from_object(Config)
# Define the database object
db = SQLAlchemy(app)
# Initialize Bootstrap connection
Bootstrap(app)
# Register Blueprings
from .artists import routes as artist_routes # noqa: E402
from .albums import routes as album_routes # noqa: E402
from .tracks import routes as track_routes # noqa: E402
from .playlists import routes as playlist_routes # noqa: E402
from .customers import routes as customer_routes # noqa: E402
from .invoices import routes as invoice_routes # noqa: E402
from .employees import routes as employee_routes # noqa: E402
app.register_blueprint(artist_routes.artists_bp)
app.register_blueprint(album_routes.albums_bp)
app.register_blueprint(track_routes.tracks_bp)
app.register_blueprint(playlist_routes.playlists_bp)
app.register_blueprint(customer_routes.customers_bp)
app.register_blueprint(invoice_routes.invoices_bp)
app.register_blueprint(employee_routes.employees_bp)
# Sample HTTP error handling
@app.errorhandler(404)
def not_found(error):
return render_template("404.html"), 404
from app import models # noqa: F401, E402
from flask import Blueprint, render_template, redirect, url_for
from flask_wtf import FlaskForm
from wtforms import StringField
from wtforms import HiddenField
from wtforms.validators import InputRequired, ValidationError
from app import db
from app.models import Artist, Album
# Setup the Blueprint
albums_bp = Blueprint(
"albums_bp", __name__, template_folder="templates", static_folder="static"
)
def does_album_exist(form, field):
album = (
db.session.query(Album)
.join(Artist)
.filter(Artist.name == form.artist.data)
.filter(Album.title == field.data)
.one_or_none()
)
if album is not None:
raise ValidationError("Album already exists", field.data)
class CreateAlbumForm(FlaskForm):
artist = HiddenField("artist")
title = StringField(
label="Albums's Name", validators=[InputRequired(), does_album_exist]
)
@albums_bp.route("/albums", methods=["GET", "POST"])
@albums_bp.route("/albums/<int:artist_id>", methods=["GET", "POST"])
def albums(artist_id=None):
form = CreateAlbumForm()
# did we get an artist id?
if artist_id is not None:
# Get the artist
artist = (
db.session.query(Artist)
.filter(Artist.artist_id == artist_id)
.one_or_none()
)
form.artist.data = artist.name
# otherwise, no artist
else:
artist = None
# Is the form valid?
if form.validate_on_submit():
# Create new Album
album = Album(title=form.title.data)
artist.albums.append(album)
db.session.add(artist)
db.session.commit()
return redirect(url_for("albums_bp.albums", artist_id=artist_id))
# Start the query for albums
query = db.session.query(Album)
# Display the albums for the artist passed?
if artist_id is not None:
query = query.filter(Album.artist_id == artist_id)
albums = query.order_by(Album.title).all()
return render_template(
"albums.html", artist=artist, albums=albums, form=form
)
{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
<div class="m-4">
{% if artist is not none %}
<div class="card" style="width: 18rem;">
<div class="card-header">Create New Album</div>
<div class="card-body">
<p class="card-text">Artist Name:&nbsp;{{ artist.name }}</p>
<form method="POST" action="{{url_for('albums_bp.albums', artist_id=artist.artist_id)}}">
{{ form.csrf_token }}
{{ render_field(form.title, placeholder=form.title.label.text) }}
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
</div>
{% endif %}
<table class="table table-striped table-bordered table-hover table-sm">
<caption>List of Albums</caption>
<thead>
<tr>
<th>Album Name</th>
</tr>
</thead>
<tbody>
{% for album in albums %}
<tr>
<td>
<a href="{{url_for('tracks_bp.tracks', album_id=album.album_id)}}">
{{ album.title }}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
\ No newline at end of file
from flask import Blueprint
from flask import render_template
from flask import redirect
from flask import url_for
from flask_wtf import FlaskForm
from wtforms import StringField
from wtforms.validators import InputRequired
from wtforms.validators import ValidationError
from app import db
from app.models import Artist
# Setup the Blueprint
artists_bp = Blueprint(
"artists_bp", __name__, template_folder="templates", static_folder="static"
)
def does_artist_exist(form, field):
artist = (
db.session.query(Artist)
.filter(Artist.name == field.data)
.one_or_none()
)
if artist is not None:
raise ValidationError("Artist already exists", field.data)
class CreateArtistForm(FlaskForm):
name = StringField(
label="Artist's Name", validators=[InputRequired(), does_artist_exist]
)
@artists_bp.route("/")
@artists_bp.route("/artists", methods=["GET", "POST"])
def artists():
form = CreateArtistForm()
# Is the form valid?
if form.validate_on_submit():
# Create new artist
artist = Artist(name=form.name.data)
db.session.add(artist)
db.session.commit()
return redirect(url_for("artists_bp.artists"))
artists = db.session.query(Artist).order_by(Artist.name).all()
return render_template("artists.html", artists=artists, form=form)
{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
<div class="m-4">
<div class="card" style="width: 18rem;">
<div class="card-header">Create New Artist</div>
<div class="card-body">
<form method="POST" action="{{url_for('artists_bp.artists')}}">
{{ form.csrf_token }}
{{ render_field(form.name, placeholder=form.name.label.text) }}
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
</div>
<table class="table table-striped table-bordered table-hover table-sm">
<caption>List of Artists</caption>
<thead>
<tr>
<th>Artist Name</th>
</tr>
</thead>
<tbody>
{% for artist in artists %}
<tr>
<td>
<a href="{{url_for('albums_bp.albums', artist_id=artist.artist_id)}}">
{{ artist.name }}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
\ No newline at end of file
from flask import Blueprint
from flask import render_template
from sqlalchemy import func
from app import db
from app.models import Customer
from app.models import Invoice
from sqlalchemy import desc
# Setup the Blueprint
customers_bp = Blueprint(
"customers_bp",
__name__,
template_folder="templates",
static_folder="static",
)
@customers_bp.route("/customers", methods=["GET"])
@customers_bp.route("/customers/<int:customer_id>", methods=["GET"])
def customers(customer_id=None):
# Start the query for customers
query = db.session.query(
Customer, func.sum(Invoice.total).label("invoices_total")
).join(Invoice)
# Display the albums for the customer passed?
if customer_id is not None:
query = query.filter(Customer.customer_id == customer_id)
results = (
query.group_by(Customer.customer_id)
.order_by(desc(func.sum(Invoice.total)))
.all()
)
return render_template("customers.html", results=results)
{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
<div class="m-4">
{# display just the playlists #}
{% if results|length > 1 %}
<table class="table table-striped table-bordered table-hover table-sm">
<caption>Customers</caption>
<thead>
<tr>
<th>Customer Name</th>
<th class="text-center">Email</th>
<th class="text-center">Total Value Of Orders</th>
</tr>
</thead>
<tbody>
{% for customer, invoices_total in results %}
<tr>
<td>
<a href="{{url_for('customers_bp.customers', customer_id=customer.customer_id)}}">
{{ customer.full_name }}
</a>
</td>
<td class="text-center">{{ customer.email }}</td>
<td class="text-right">{{ '%.2f'|format(invoices_total) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{# display the playlist name and the tracks #}
{% else %}
{% set customer, invoices_total = results[0] %}
<div class="card" style="width: 18rem;">
<div class="card-header">Customer</div>
<div class="card-body">
<p class="card-text">Name:&nbsp;{{ customer.full_name }}</p>
<p class="card-text">Address:&nbsp;{{ customer.address }}</p>
<p class="card-text">
City:&nbsp;{{ customer.city }},&nbsp;{{ customer.state }}&nbsp;&nbsp;{{ customer.postal_code }}</p>
<p class="card-text">Phone:&nbsp;{{ customer.phone }}</p>
<p class="card-text">Email:&nbsp;{{ customer.email }}</p>
<p class="card-text">Support Rep:&nbsp;
<a href="{{url_for('employees_bp.employees', employee_id=customer.support_rep_id)}}">
{{ customer.support_rep.full_name }}
</a>
</p>
</div>
</div>
<table class="table table-striped table-bordered table-hover table-sm">
<caption>Invoices</caption>
<thead>
<tr>
<th class="text-center">Invoice Id</th>
<th class="text-center">Invoice Date</th>
<th class="text-right">Total</th>
</tr>
</thead>
<tbody>
{% set invoices = customer.invoices %}
{% for invoice in invoices %}
<tr>
<td class="text-center">
<a href="{{url_for('invoices_bp.invoices', invoice_id=invoice.invoice_id)}}">
{{ invoice.invoice_id}}
</a>
</td>
<td class="text-center">{{ invoice.invoice_date }}</td>
<td class="text-right">{{ invoice.total }}</td>
</tr>
{% endfor %}
<tr>
<td></td>
<td class="text-right">Total</td>
<td class="text-right">{{ invoices_total }}</td>
</tr>
</tbody>
</table>
{% endif %}
</div>
</div>
{% endblock %}
\ No newline at end of file
from flask import Blueprint
from flask import render_template
from app import db
from app.models import Employee
# Setup the Blueprint
employees_bp = Blueprint(
"employees_bp",
__name__,
template_folder="templates",
static_folder="static",
)
@employees_bp.route("/employees", methods=["GET"])
@employees_bp.route("/employees/<int:employee_id>", methods=["GET"])
def employees(employee_id=None):
# Start the query for employees
query = db.session.query(Employee)
# Display the employee for the employee id passed?
if employee_id is not None:
query = query.filter(Employee.employee_id == employee_id)
employees = query.order_by(Employee.employee_id).all()
return render_template("employees.html", employees=employees)
{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
<div class="m-4">
{# display just the employees #}
{% if employees|length > 1 %}
<table class="table table-striped table-bordered table-hover table-sm">
<caption>Employees</caption>
<thead>
<tr>
<th>ID</th>
<th class="text-center">Name</th>
<th class="text-center">Title</th>
<th class="text-center">Reports To</th>
</tr>
</thead>
<tbody>
{% for employee in employees %}
<tr>
<td>{{ employee.employee_id }}</td>
<td>
<a href="{{url_for('employees_bp.employees', employee_id=employee.employee_id)}}">
{{ employee.full_name}}
</a>
</td>
<td class="text-center">{{ employee.title }}</td>
<td class="text-center">
{% if employee.reports_to_id is none %}
Top of org chart
{% else %}
<a href="{{url_for('employees_bp.employees', employee_id=employee.reports_to_id)}}">
{{ employee.reports_to.full_name }}
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{# display the employee information #}
{% else %}
{% set employee = employees[0] %}
<div class="card" style="width: 18rem;">
<div class="card-header">Employee</div>
<div class="card-body">
<p class="card-text">Name:&nbsp;{{ employee.full_name }}</p>
<p class="card-text">Title:&nbsp;{{ employee.title }}</p>
<p class="card-text">Hire Date:&nbsp;{{ employee.hire_date }}</p>
<p class="card-text">Birth Date:&nbsp;{{ employee.birth_date }}</p>
<p class="card-text">Address:&nbsp;{{ employee.address }}</p>
<p class="card-text">City:&nbsp;{{ employee.city }}</p>
<p class="card-text">State:&nbsp;{{ employee.state }}</p>
<p class="card-text">Postal Code:&nbsp{{ employee.postal_code }}</p>
<p class="card-text">Phone:&nbsp;{{ employee.phone }}</p>
<p class="card-text">Phone:&nbsp;{{ employee.fax }}</p>
<p class="card-text">Email:&nbsp;{{ employee.email }}</p>
{% if employee.reports_to_id is not none %}
<p class="card-text">Reports To:&nbsp;
<a href="{{url_for('employees_bp.employees', employee_id=employee.reports_to_id)}}">
{{ employee.reports_to.full_name }}
</a>
</p>
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}
from flask import Blueprint
from flask import render_template
from app import db
from app.models import Invoice
# Setup the Blueprint
invoices_bp = Blueprint(
"invoices_bp",
__name__,
template_folder="templates",
static_folder="static",
)
@invoices_bp.route("/invoices", methods=["GET"])
@invoices_bp.route("/invoices/<int:invoice_id>", methods=["GET"])
def invoices(invoice_id=None):
# Start the query for invoices
query = db.session.query(Invoice)
# Display the invoice for the invoice id passed?
if invoice_id is not None:
query = query.filter(Invoice.invoice_id == invoice_id)
invoices = query.order_by(Invoice.invoice_id).all()
return render_template("invoices.html", invoices=invoices)
{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
<div class="m-4">
{# display just the invoices #}
{% if invoices|length > 1 %}
<table class="table table-striped table-bordered table-hover table-sm">
<caption>Invoices</caption>
<thead>
<tr>
<th class="text-center">Invoice Id</th>
<th class="text-center">Customer Name</th>
<th class="text-center">Invoice Date</th>
<th class="text-center">Billing Address</th>
<th class="text-right">Total</th>
</tr>
</thead>
<tbody>
{% for invoice in invoices %}
<tr>
<td>
<a href="{{url_for('invoices_bp.invoices', invoice_id=invoice.invoice_id)}}">
{{ invoice.invoice_id }}
</a>
</td>
<td>
<a href="{{url_for('customers_bp.customers', customer_id=invoice.customer.customer_id)}}">
{{ invoice.customer.full_name }}
</a>
</td>
<td class="text-center">{{ invoice.invoice_date }}</td>
<td class="text-center">
{{ invoice.billing_address }}&nbsp;
{{ invoice.billing_city }},&nbsp;
{{ invoice.billing_state }}&nbsp;&nbsp;
{{ invoice.billing_postal_code }}&nbsp;
{{ invoice.billing_country }}
</td>
<td class="text-right">{{ '%.2f'|format(invoice.total) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{# display the invoice items #}
{% else %}
{% set invoice = invoices[0] %}
{% set invoice_items = invoices[0].invoice_items %}
<div class="card" style="width: 18rem;">
<div class="card-header">Invoice</div>
<div class="card-body">
<p class="card-text">Customer Name:&nbsp;{{ invoice.customer.full_name }}</p>
<p class="card-text">Date:&nbsp;{{ invoice.invoice_date }}</p>
<p class="card-text">Billing Address:&nbsp;{{ invoice.billing_address }}</p>
<p class="card-text">Billing City:&nbsp;{{ invoice.billing_city }}</p>
<p class="card-text">Billing State:&nbsp;{{ invoice.billing_state }}</p>
<p class="card-text">Billing Postal Code:&nbsp{{ invoice.billing_postal_code }}</p>
<p class="card-text">Billing Country:&nbsp;{{ invoice.billing_country }}</p>
</div>
</div>
<table class="table table-striped table-bordered table-hover table-sm">
<caption>Invoice Items</caption>
<thead>
<tr>
<th class="text-center">ID</th>
<th class="text-center">Track Id</th>
<th class="text-center">Quantity</th>
<th class="text-center">Unit Price</th>
</tr>
</thead>
<tbody>
{% for invoice_item in invoice_items %}
<tr>
<td class="text-center">{{ invoice_item.track_id }}</td>
<td class="text-center">{{ invoice_item.invoice_id }}</td>
<td class="text-center">{{ invoice_item.quantity }}</td>
<td class="text-right">{{ invoice_item.unit_price }}</td>
</tr>
{% endfor %}
<tr>
<td></td>
<td></td>
<td class="text-right">Total</td>
<td class="text-right">{{ invoice.total }}</td>
</tr>
</tbody>
</table>
{% endif %}
</div>
</div>
{% endblock %}
\ No newline at end of file
# coding: utf-8
from app import db
from sqlalchemy.ext.hybrid import hybrid_property
class Artist(db.Model):
__tablename__ = "artists"
artist_id = db.Column("ArtistId", db.Integer, primary_key=True)
name = db.Column("Name", db.String(120))
albums = db.relationship("Album", backref="artist")
class Employee(db.Model):
__tablename__ = "employees"
employee_id = db.Column("EmployeeId", db.Integer, primary_key=True)
last_name = db.Column("LastName", db.String(20), nullable=False)
first_name = db.Column("FirstName", db.String(20), nullable=False)
title = db.Column("Title", db.String(30))
reports_to_id = db.Column(
"ReportsTo", db.ForeignKey("employees.EmployeeId"), index=True
)
reports_to = db.relationship(
"Employee", uselist=False, remote_side=[employee_id]
)
birth_date = db.Column("BirthDate", db.DateTime)
hire_date = db.Column("HireDate", db.DateTime)
address = db.Column("Address", db.String(70))
city = db.Column("City", db.String(40))
state = db.Column("State", db.String(40))
country = db.Column("Country", db.String(40))
postal_code = db.Column("PostalCode", db.String(10))
phone = db.Column("Phone", db.String(24))
fax = db.Column("Fax", db.String(24))
email = db.Column("Email", db.String(60))
parent = db.relationship(
"Employee", remote_side=[employee_id], backref="reporting"
)
@hybrid_property
def full_name(self):
return f"{self.first_name} {self.last_name}"
class Genre(db.Model):
__tablename__ = "genres"
genre_id = db.Column("GenreId", db.Integer, primary_key=True)
name = db.Column("Name", db.String(120))
tracks = db.relationship("Track", backref="genre")
class MediaType(db.Model):
__tablename__ = "media_types"
media_type_id = db.Column("MediaTypeId", db.Integer, primary_key=True)
name = db.Column("Name", db.String(120))
tracks = db.relationship("Track", backref="media_type")
class Playlist(db.Model):
__tablename__ = "playlists"
playlist_id = db.Column("PlaylistId", db.Integer, primary_key=True)
name = db.Column("Name", db.String(120))
tracks = db.relationship(
"Track", secondary="playlist_track", back_populates="playlists"
)
class Album(db.Model):
__tablename__ = "albums"
album_id = db.Column("AlbumId", db.Integer, primary_key=True)
title = db.Column("Title", db.String(160), nullable=False)
artist_id = db.Column(
"ArtistId",
db.ForeignKey("artists.ArtistId"),
nullable=False,
index=True,
)
tracks = db.relationship("Track", backref="album")
class Customer(db.Model):
__tablename__ = "customers"
customer_id = db.Column("CustomerId", db.Integer, primary_key=True)
first_name = db.Column("FirstName", db.String(40), nullable=False)
last_name = db.Column("LastName", db.String(20), nullable=False)
company = db.Column("Company", db.String(80))
address = db.Column("Address", db.String(70))
city = db.Column("City", db.String(40))
state = db.Column("State", db.String(40))
country = db.Column("Country", db.String(40))
postal_code = db.Column("PostalCode", db.String(10))
phone = db.Column("Phone", db.String(24))
fax = db.Column("Fax", db.String(24))
email = db.Column("Email", db.String(60), nullable=False)
support_rep_id = db.Column(
"SupportRepId", db.ForeignKey("employees.EmployeeId"), index=True
)
support_rep = db.relationship(
"Employee", backref=db.backref("customers", uselist=False)
)
invoices = db.relationship("Invoice", backref="customer")
@hybrid_property
def full_name(self):
return f"{self.first_name} {self.last_name}"
class Invoice(db.Model):
__tablename__ = "invoices"
invoice_id = db.Column("InvoiceId", db.Integer, primary_key=True)
customer_id = db.Column(
"CustomerId",
db.ForeignKey("customers.CustomerId"),
nullable=False,
index=True,
)
invoice_date = db.Column("InvoiceDate", db.DateTime, nullable=False)
billing_address = db.Column("BillingAddress", db.String(70))
billing_city = db.Column("BillingCity", db.String(40))
billing_state = db.Column("BillingState", db.String(40))
billing_country = db.Column("BillingCountry", db.String(40))
billing_postal_code = db.Column("BillingPostalCode", db.String(10))
total = db.Column("Total", db.Float, nullable=False)
invoice_items = db.relationship("InvoiceItem", backref="invoice")
class Track(db.Model):
__tablename__ = "tracks"
track_id = db.Column("TrackId", db.Integer, primary_key=True)
name = db.Column("Name", db.String(200), nullable=False)
album_id = db.Column(
"AlbumId", db.ForeignKey("albums.AlbumId"), index=True
)
media_type_id = db.Column(
"MediaTypeId",
db.ForeignKey("media_types.MediaTypeId"),
nullable=False,
index=True,
)
genre_id = db.Column(
"GenreId", db.ForeignKey("genres.GenreId"), index=True
)
composer = db.Column("Composer", db.String(220))
milliseconds = db.Column("Milliseconds", db.Integer, nullable=False)
bytes = db.Column("Bytes", db.Integer)
unit_price = db.Column("UnitPrice", db.Float, nullable=False)
invoice_items = db.relationship("InvoiceItem", backref="track")
playlists = db.relationship(
"Playlist", secondary="playlist_track", back_populates="tracks"
)
class InvoiceItem(db.Model):
__tablename__ = "invoice_items"
invoice_line_id = db.Column("InvoiceLineId", db.Integer, primary_key=True)
invoice_id = db.Column(
"InvoiceId",
db.ForeignKey("invoices.InvoiceId"),
nullable=False,
index=True,
)
track_id = db.Column(
"TrackId", db.ForeignKey("tracks.TrackId"), nullable=False, index=True
)
unit_price = db.Column("UnitPrice", db.Float, nullable=False)
quantity = db.Column("Quantity", db.Integer, nullable=False)
playlist_track = db.Table(
"playlist_track",
db.Column(
"PlaylistId",
db.Integer,
db.ForeignKey("playlists.PlaylistId"),
primary_key=True,
nullable=False,
),
db.Column(
"TrackId",
db.Integer,
db.ForeignKey("tracks.TrackId"),
primary_key=True,
nullable=False,
index=True,
),
)
from flask import Blueprint
from flask import render_template
from app import db
from app.models import Playlist
# Setup the Blueprint
playlists_bp = Blueprint(
"playlists_bp",
__name__,
template_folder="templates",
static_folder="static",
)
@playlists_bp.route("/playlists", methods=["GET"])
@playlists_bp.route("/playlists/<int:playlist_id>", methods=["GET"])
def playlists(playlist_id=None):
# Start the query for playlists
query = db.session.query(Playlist)
# Display the tracks for the playlist passed?
if playlist_id is not None:
query = query.filter(Playlist.playlist_id == playlist_id)
playlists = query.order_by(Playlist.name).all()
return render_template("playlists.html", playlists=playlists)
{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
<div class="m-4">
{# display just the playlists #}
{% if playlists|length > 1 %}
<table class="table table-striped table-bordered table-hover table-sm">
<caption>Playlists</caption>
<thead>
<tr>
<th>Playlist Name</th>
</tr>
</thead>
<tbody>
{% for playlist in playlists %}
<tr>
<td>
<a href="{{url_for('playlists_bp.playlists', playlist_id=playlist.playlist_id)}}">
{{ playlist.name }}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{# display the playlist name and the tracks #}
{% else %}
{% set playlist = playlists[0] %}
{% set tracks = playlist.tracks %}
<div class="card" style="width: 18rem;">
<div class="card-header">Playlist Tracks</div>
<div class="card-body">
<p class="card-text">Playlist Name:&nbsp;{{ playlist.name }}</p>
</div>
</div>
<table class="table table-striped table-bordered table-hover table-sm">
<caption>Playlist Tracks</caption>
<thead>
<tr>
<th>Track Name</th>
<th class="text-center">Media Type</th>
<th class="text-center">Genre</th>
<th class="text-center">Unit Price</th>
</tr>
</thead>
<tbody>
{% for track in tracks %}
<tr>
<td>{{ track.name }}</td>
<td class="text-center">{{ track.media_type.name }}</td>
<td class="text-center">{{ track.genre.name }}</td>
<td class="text-right">{{ track.unit_price }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
</div>
{% endblock %}
\ No newline at end of file
body {
padding-top: 50px;
}
.card {
margin-bottom: 10px;
}
/*
* Javascript to run the app
*/
$(document).ready(function() {
let base_path = $(location)
.attr("pathname")
.toLowerCase()
.split("/")[1];
// clear default active link
$(".navbar-nav a.active")
.removeClass("active");
// set new active link based on location
// if (base_path === "albums")
// $(".navbar-nav a[href$='/albums']")
// .addClass("active");
$(`.navbar-nav a[href$='/${base_path}']`)
.addClass("active");
});
{% extends "base.html" %}
{% block content %}
<div class="jumbotron">
<h1 class="display-4">404</h1>
<p class="lead">
Sorry, you've reached a page this site doesn't know about.
</p>
<a class="btn btn-primary btn-lg" href="{{url_for('artists_bp.artists')}}">Home Page</a>
</div>
{% endblock %}
\ No newline at end of file
{% extends "bootstrap/base.html" %}
{% from "bootstrap/base.html" import render_field %}
{% block title %}
Chinook Database Web Server
{% endblock %}
{% block styles %}
{{ super() }}
<link rel="stylesheet" href="{{url_for('static', filename='css/base.css')}}">
{% endblock %}
{% block navbar %}
<nav class="navbar navbar-expand-lg fixed-top navbar-dark" style="background-color: #361Ddc;">
<a class="navbar-brand" href="#">Example 3</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="/artists">Artists</a>
<a class="nav-item nav-link" href="/albums">Albums</a>
<a class="nav-item nav-link" href="/playlists">Playlists</a>
<a class="nav-item nav-link" href="/customers">Customers</a>
<a class="nav-item nav-link" href="/invoices">Invoices</a>
<a class="nav-item nav-link" href="/employees">Employees</a>
</div>
</div>
</nav>
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="{{url_for('static', filename='js/base.js')}}"></script>
{% endblock %}
{% macro render_field(field) %}
<div class="form-group">
{{ field(class_='form-control', **kwargs)|safe }}
{% if field.errors %}
{% for error in field.errors %}
<div class="alert alert-danger" role="alert" style="margin-top: 10px;">
{{ error }}
</div>
{% endfor %}
{% endif %}
</div>
{% endmacro %}
{% macro render_select(field) %}
<div class="form-group">
{{ field(class_='form-control', **kwargs)|safe }}
{% if field.errors %}
{% for error in field.errors %}
<div class="alert alert-danger" role="alert" style="margin-top: 10px;">
{{ error }}
</div>
{% endfor %}
{% endif %}
</div>
{% endmacro %}
\ No newline at end of file
from flask import Blueprint
from flask import render_template
from flask_wtf import FlaskForm
from wtforms import StringField
from wtforms import IntegerField
from wtforms import FloatField
from wtforms import SelectField
from wtforms import HiddenField
from wtforms.validators import InputRequired
from wtforms.validators import ValidationError
from app import db
from app.models import Artist
from app.models import Album
from app.models import Track
from app.models import MediaType
from app.models import Genre
# Setup the Blueprint
tracks_bp = Blueprint(
"tracks_bp", __name__, template_folder="templates", static_folder="static"
)
def does_artist_exist(form, field):
artist = (
db.session.query(Artist)
.filter(Artist.name == field.data)
.one_or_none()
)
if artist is not None:
raise ValidationError("Artist already exists", field.data)
def does_album_exist(form, field):
album = (
db.session.query(Album).filter(Album.title == field.data).one_or_none()
)
if album is not None:
raise ValidationError("Album already exists", field.data)
def does_track_exist(form, field):
track = (
db.session.query(Track)
.join(Album)
.join(Artist)
.filter(Artist.name == form.artist.data)
.filter(Album.title == form.album.data)
.filter(Track.name == field.data)
.one_or_none()
)
if track is not None:
raise ValidationError("Track already exists", field.data)
class CreateTrackForm(FlaskForm):
artist = HiddenField("artist")
album = HiddenField("album")
name = StringField(
label="Track's Name", validators=[InputRequired(), does_track_exist]
)
media_type = SelectField(label="Media Type", validators=[InputRequired()])
genre = SelectField(label="Genre", validators=[InputRequired()])
composer = StringField(label="Composer")
milliseconds = IntegerField(
label="Time in Milliseconds", validators=[InputRequired()]
)
bytes = IntegerField(label="Size in Bytes", validators=[InputRequired()])
unit_price = FloatField(label="Unit Price", validators=[InputRequired()])
@tracks_bp.route("/tracks/<int:album_id>", methods=["GET", "POST"])
def tracks(album_id=None):
form = CreateTrackForm()
# Get MediaType information and populate the form
form.media_type.choices = [
(str(media_type.media_type_id), media_type.name)
for media_type in MediaType.query.order_by(MediaType.media_type_id)
]
# Get Genre information and populate the form
form.genre.choices = [
(str(genre.genre_id), genre.name)
for genre in Genre.query.order_by(Genre.genre_id)
]
# Get the album
album = (
db.session.query(Album)
.filter(Album.album_id == album_id)
.one_or_none()
)
form.album.data = album.title
artist = album.artist
form.artist.data = artist.name
# Is the form valid?
if form.validate_on_submit():
# Create new Track
track = Track(
name=form.name.data,
media_type_id=form.media_type.data,
genre_id=form.genre.data,
composer=form.composer.data,
milliseconds=form.milliseconds.data,
bytes=form.bytes.data,
unit_price=form.unit_price.data,
)
album.tracks.append(track)
db.session.add(album)
db.session.commit()
# Get the tracks
tracks = db.session.query(Track).filter(Track.album_id == album_id).all()
return render_template(
"tracks.html", artist=artist, album=album, tracks=tracks, form=form
)
{% extends "base.html" %}
{% block content %}
<div class="container-fluid">
<div class="m-4">
{% if artist is not none %}
<div class="card" style="width: 18rem;">
<div class="card-header">Create New Track</div>
<div class="card-body">
<p class="card-text">Artist's Name:&nbsp;{{ artist.name }}</p>
<p class="card-text">Album's Name:&nbsp;{{ album.title }}</p>
<form method="POST" action="{{url_for('tracks_bp.tracks', album_id=album.album_id)}}">
{{ form.csrf_token }}
{{ render_field(form.artist) }}
{{ render_field(form.album) }}
{{ render_field(form.name, placeholder=form.name.label.text) }}
{{ render_select(form.media_type, placeholder=form.media_type.label.text) }}
{{ render_select(form.genre, placeholder=form.genre.label.text) }}
{{ render_field(form.composer, placeholder=form.composer.label.text) }}
{{ render_field(form.milliseconds, placeholder=form.milliseconds.label.text) }}
{{ render_field(form.bytes, placeholder=form.bytes.label.text) }}
{{ render_field(form.unit_price, placeholder=form.unit_price.label.text) }}
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
</div>
{% endif %}
<table class="table table-striped table-bordered table-hover table-sm">
<caption>List of Tracks</caption>
<thead>
<tr>
<th>Track Name</th>
<th class="text-center">Media Type</th>
<th class="text-center">Genre</th>
<th class="text-center">Unit Price</th>
</tr>
</thead>
<tbody>
{% for track in tracks %}
<tr>
<td>{{ track.name }}</td>
<td class="text-center">{{ track.media_type.name }}</td>
<td class="text-center">{{ track.genre.name }}</td>
<td class="text-right">{{ track.unit_price }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
\ No newline at end of file
from app import app
if __name__ == "__main__":
app.run("0.0.0.0", port=5000)
import os
import json
from pathlib import Path
from dotenv import load_dotenv
# Load the environment variables from .env file
path = Path(__file__).parent / ".env"
if path.exists():
load_dotenv()
else:
raise IOError(".env file not found")
class Config:
base_path = Path(__file__).resolve().parent.parent.parent
db_path = base_path / "data" / "chinook.db"
SECRET_KEY = os.getenv("SECRET_KEY")
SQLALCHEMY_DATABASE_URI = f"sqlite:///{str(db_path)}"
SQLALCHEMY_TRACK_MODIFICATIONS = json.loads(
os.getenv("SQLALCHEMY_TRACK_MODIFICATIONS").lower()
)
SQLALCHEMY_ECHO = json.loads(os.getenv("SQLALCHEMY_ECHO").lower())
DEBUG = json.loads(os.getenv("DEBUG").lower())
"""
This program gathers information from the temp_data.csv file about temperature
"""
from pkg_resources import resource_filename
from datetime import datetime
from datetime import timedelta
from sqlalchemy import create_engine
from sqlalchemy import Column, String, Integer, Float, Date
from sqlalchemy.sql import func, and_, asc, desc
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class TemperatureData(Base):
__tablename__ = "temperature_data"
id = Column(Integer, primary_key=True)
name = Column(String)
date = Column(Date)
value = Column(Float)
def get_average_temp_by_date(date_string, session) -> float:
"""
This function gets the average temperature for all the samples
taken by the students by date
:param date_string: date to find average temperature for
:param session: SqlAlchemy session
:return: average temp for date, or None if not found
"""
target_date = datetime.strptime(date_string, "%Y-%m-%d").date()
min_date = target_date + timedelta(days=-3)
max_date = target_date + timedelta(days=3)
result = (
session.query(func.avg(TemperatureData.value))
.filter(
and_(
TemperatureData.date >= min_date,
TemperatureData.date <= max_date,
)
)
.one()
)
return result[0]
def get_average_temp_sorted(direction: str, session) -> list:
if direction.lower() not in ["asc", "desc"]:
raise Exception(f"Unknown direction: {direction}")
dir = asc if direction.lower() == "asc" else desc
results = (
session.query(
TemperatureData.date,
func.avg(TemperatureData.value).label("average_temp"),
)
.group_by(TemperatureData.date)
.order_by(dir("average_temp"))
.all()
)
return results
def main():
print("starting")
# Connect to the database using SqlAlchemy
sqlite_filepath = resource_filename("project.data", "temp_data.db")
engine = create_engine(f"sqlite:///{sqlite_filepath}")
Session = sessionmaker()
Session.configure(bind=engine)
session = Session()
# Get the average temperature by date
date_string = "2019-02-10"
average_temp = get_average_temp_by_date(date_string, session)
print(f"Average temp {date_string}: {average_temp:.2f}")
print()
# Get the average temps for the year sorted ascending or descending
average_temps = get_average_temp_sorted("asc", session)
for row in average_temps:
print(f"Date: {row.date}, average temp: {row.average_temp:.2f}")
print()
print("finished")
if __name__ == "__main__":
main()
# Example 4
This example uses the raw author_book_publisher.csv file to
get data into the program and run various python functions
on it.
The csv file uses redundant data to hold relationship data
in the file. The main.py program examines this file to use
those reletionships to get different kinds of information
from the file.
\ No newline at end of file
"""
This is the example 4 program file
"""
import csv
import copy
from pkg_resources import resource_filename
from typing import List
from collections import defaultdict
from uuid import uuid4
from treelib import Tree
def get_author_book_publisher_data(filepath: str) -> List:
"""
This function gets the temperature data from the csv file
"""
with open(filepath) as csvfile:
csv_reader = csv.DictReader(csvfile)
data = [row for row in csv_reader]
return data
def get_total_number_of_books_by_publishers(data, direction) -> List:
"""
:param data: author/book/publisher data
:param direction: direction to sort the data by
:return: List of sorted data
"""
if direction not in ["asc", "desc"]:
raise Exception(f"Unknown direction: {direction}")
# Get total number of books for each publisher
publishers = defaultdict(int)
for row in data:
publishers[row["publisher"]] += 1
# Convert the dictionary to a list of tuples and sort it
retval = [(k, v) for k, v in publishers.items()]
return sorted(
retval,
key=lambda v: v[1],
reverse=False if direction == "asc" else True,
)
def get_total_number_of_authors_by_publishers(data, direction: str) -> List:
"""
:param data: author/book/publisher data
:param direction: direction to sort the data by
:return: List of sorted data
"""
if direction not in ["asc", "desc"]:
raise Exception("Unknown direction", direction)
# Get total number of authors for each publisher
publishers = defaultdict(list)
for row in data:
publishers[row["publisher"]] = []
for row in data:
author = f"{row['fname']} {row['lname']}"
if author not in publishers[row["publisher"]]:
publishers[row["publisher"]].append(author)
retval = [(k, len(v)) for k, v in publishers.items()]
return sorted(
retval,
key=lambda v: v[1],
reverse=False if direction == "asc" else True,
)
def get_authors(data) -> List:
"""
This function returns a list of authors, including their hierarchical
data
:param data: author/book/publisher data
:return: list of authors data
"""
# Get the authors
authors = {f"{row['fname']} {row['lname']}": {} for row in data}
# Get the books associated with the authors
for row in data:
author = f"{row['fname']} {row['lname']}"
title = row["title"]
authors[author][title] = set()
# Get the publisher associated with the book
for row in data:
author = f"{row['fname']} {row['lname']}"
title = row["title"]
publisher = row["publisher"]
authors[author][title].add(publisher)
return authors
def add_new_book(data, author_name, book_title, publisher_name):
"""
This function adds a new book to the data
:param data: author/book/publisher data
:param author_name: author's name
:param book_title: book title
:param publisher_name: publishers name
:return: updated data
"""
# Create a new copy of the passed in data
new_data = copy.deepcopy(data)
# Does the book exist?
books = {row["title"] for row in data}
if book_title in books:
raise Exception("Book exists", book_title)
fname, lname = author_name.split(" ")
# Does the author exist?
authors = {f"{row['fname']} {row['lname']}" for row in data}
if author_name not in authors:
raise Exception("No author found", author_name)
# Does the publisher exist?
publishers = {row["publisher"] for row in data}
if publisher_name not in publishers:
raise Exception("No publisher found", publisher_name)
# Add the new book
new_data.append(
{
"fname": fname,
"lname": lname,
"title": book_title,
"publisher": publisher_name,
}
)
return new_data
def output_hierarchical_author_data(authors):
"""
This function outputs the author/book/publisher information in
a hierarchical manner
:param authors: the collection of root author objects
:return: None
"""
authors_tree = Tree()
authors_tree.create_node("Authors", "authors")
for author, books in authors.items():
authors_tree.create_node(author, author, parent="authors")
for book, publishers in books.items():
authors_tree.create_node(book, book, parent=author)
for publisher in publishers:
authors_tree.create_node(publisher, uuid4(), parent=book)
# Output the hierarchical authors data
print(authors_tree.show())
def main():
"""
The main entry point of the program
"""
print("starting")
# Connect to the database using SqlAlchemy
filepath = resource_filename("project.data", "author_book_publisher.csv")
author_book_publisher_data = get_author_book_publisher_data(filepath)
# Get the total number of books printed by each publisher
total_books_by_publisher = get_total_number_of_books_by_publishers(
author_book_publisher_data, "desc"
)
for publisher, total_books in total_books_by_publisher:
print(f"Publisher: {publisher}, total books: {total_books}")
print()
# Get the total number of authors each publisher publishes
total_authors_by_publisher = get_total_number_of_authors_by_publishers(
author_book_publisher_data, "desc"
)
for publisher, total_authors in total_authors_by_publisher:
print(f"Publisher: {publisher}, total authors: {total_authors}")
print()
# Output hierarchical authors data
authors = get_authors(author_book_publisher_data)
output_hierarchical_author_data(authors)
# Add a new book to the data structure
author_book_publisher_data = add_new_book(
author_book_publisher_data,
author_name="Stephen King",
book_title="The Stand",
publisher_name="Random House",
)
# Output the updated hierarchical authors data
authors = get_authors(author_book_publisher_data)
output_hierarchical_author_data(authors)
print("finished")
if __name__ == "__main__":
main()
# Example 5
This example uses Sqlite and SQL queries to access the
author_book_publisher.db database file to
get data into the program and run various python functions
on it.
The database captures the relationships between tables, and
this is used to generate interesting data about the database.
However, the original CSV file is essentially re-created in
the *get_authors()* function in order to create the authors
hierarchical data necessary to generate the tree view
presented by the main program.
"""
Example 5 program file
"""
from pkg_resources import resource_filename
import sqlite3
from uuid import uuid4
from typing import List
from treelib import Tree
def get_total_number_of_books_by_publishers(connection, direction) -> List:
"""
:param connection: connection to the database
:return: List of sorted data
"""
if direction not in ["asc", "desc"]:
raise Exception("Unknown direction", direction)
cursor = connection.cursor()
sql = f"""
SELECT
p.name as publisher_name,
count(b.title) as total_books
FROM publisher p
JOIN book_publisher bp on bp.publisher_id = p.publisher_id
JOIN book b on b.book_id = bp.book_id
GROUP BY publisher_name
ORDER BY total_books {direction};
"""
result = cursor.execute(sql).fetchall()
return result
def get_total_number_of_authors_by_publishers(connection, direction) -> List:
"""
:param connection: connection to the database
:return: List of sorted data
"""
if direction not in ["asc", "desc"]:
raise Exception("Unknown direction", direction)
cursor = connection.cursor()
sql = f"""
SELECT
p.name as publisher_name,
count(a.lname) as total_authors
FROM publisher p
JOIN author_publisher ap on p.publisher_id = ap.publisher_id
JOIN author a on ap.author_id = a.author_id
GROUP BY publisher_name
ORDER BY total_authors {direction};
"""
result = cursor.execute(sql).fetchall()
return result
def get_authors(connection) -> List:
"""
This method gets the authors data an builds a hierarchical data
structure from there for use by the treelib
:param connection: connection to the database
:return: list of authors data
"""
cursor = connection.cursor()
sql = """
SELECT
a.fname || ' ' || a.lname as author,
b.title,
p.name
FROM author a
JOIN book b on b.author_id = a.author_id
JOIN author_publisher ap on ap.author_id = a.author_id
JOIN publisher p on p.publisher_id = ap.publisher_id
"""
result = cursor.execute(sql).fetchall()
# Get the authors
authors = {row[0]: {} for row in result}
# Get the books associated with the authors
for row in result:
author = row[0]
title = row[1]
authors[author][title] = set()
# Get the publisher associated with the book
for row in result:
author = row[0]
title = row[1]
publisher = row[2]
authors[author][title].add(publisher)
return authors
def add_new_book(connection, author_name, book_title, publisher_name):
"""
This function adds a new book to the database
:param session: database session to work with
:param author_name: authors full name
:param book_title: book title
:param publisher_name: publisher of book
:return: None
"""
connection.row_factory = sqlite3.Row
cursor = connection.cursor()
# Does the book exist?
sql = """SELECT 1 FROM book WHERE title = ?"""
book = cursor.execute(sql, (book_title,)).fetchone()
if book is not None:
raise Exception("Book exists", book_title)
# Get author
sql = """
SELECT
author_id
FROM author
WHERE author.fname = ?
AND author.lname = ?
"""
fname, lname = author_name.split(" ")
author = cursor.execute(sql, (fname, lname)).fetchone()
# Did we get an author?
if author is None:
raise Exception("No author found", author_name)
# Get publisher
sql = """
SELECT
publisher_id
FROM publisher
WHERE name = ?
"""
publisher = cursor.execute(sql, (publisher_name,)).fetchone()
# Did we get a publisher?
if publisher is None:
raise Exception("No publisher found", publisher_name)
# Add the book
sql = """
INSERT INTO book
(title, author_id)
VALUES(?, ?)
"""
book_id = cursor.execute(sql, (book_title, author["author_id"])).lastrowid
# Update the relationships
sql = """
INSERT INTO book_publisher
(book_id, publisher_id)
VALUES(?, ?)
"""
cursor.execute(sql, (book_id, publisher["publisher_id"]))
connection.commit()
def output_hierarchical_author_data(authors):
"""
This function outputs the author/book/publisher information in
a hierarchical manner
:param authors: the collection of root author objects
:return: None
"""
authors_tree = Tree()
authors_tree.create_node("Authors", "authors")
for author, books in authors.items():
authors_tree.create_node(author, author, parent="authors")
for book, publishers in books.items():
authors_tree.create_node(book, book, parent=author)
for publisher in publishers:
authors_tree.create_node(publisher, uuid4(), parent=book)
# Output the hierarchical authors data
print(authors_tree.show())
def main():
"""
Main program entry point
"""
print("starting")
# connect to the sqlite database
sqlite_filepath = resource_filename(
"project.data", "author_book_publisher.db"
)
connection = sqlite3.connect(sqlite_filepath)
# Get the total number of books printed by each publisher
total_books_by_publisher = get_total_number_of_books_by_publishers(
connection, "desc"
)
for publisher, total_books in total_books_by_publisher:
print(f"Publisher: {publisher}, total books: {total_books}")
print()
# Get the total number of authors each publisher publishes
total_authors_by_publisher = get_total_number_of_authors_by_publishers(
connection, "desc"
)
for publisher, total_authors in total_authors_by_publisher:
print(f"Publisher: {publisher}, total authors: {total_authors}")
print()
# Output hierarchical authors data
authors = get_authors(connection)
output_hierarchical_author_data(authors)
# add a new book
add_new_book(
connection,
author_name="Stephen King",
book_title="The Stand",
publisher_name="Random House",
)
# Output hierarchical authors data
authors = get_authors(connection)
output_hierarchical_author_data(authors)
print("finished")
if __name__ == "__main__":
main()
# Example 6
This example uses SqlAlcheym to access the author_book_publisher.db
sqlite file to get data into the program and run various python functions
on it.
The main.py program file shows how to use the objects returned
by SqlAlchemy, and the relationships coded into them, to retreive
the same information the previous example programs did.
\ No newline at end of file
"""
This program gathers information from the temp_data.csv file about temperature
"""
from pkg_resources import resource_filename
from typing import List
from uuid import uuid4
from sqlalchemy import create_engine
from sqlalchemy import and_
from sqlalchemy.sql import func, asc, desc
from sqlalchemy.orm import sessionmaker
from treelib import Tree
from project.modules.models import Author
from project.modules.models import Book
from project.modules.models import Publisher
def get_total_number_of_books_by_publishers(session, direction: str) -> List:
"""
:param session: database session to work with
:param direction:
:return:
"""
if direction not in ["asc", "desc"]:
raise Exception(f"Unknown direction: {direction}")
dir = desc if direction == "desc" else asc
results = (
session.query(
Publisher.name, func.count(Book.title).label("total_books")
)
.join(Publisher.books)
.group_by(Publisher.name)
.order_by(dir("total_books"))
)
return results
def get_total_number_of_authors_by_publishers(session, direction: str) -> List:
"""
:param session: database session to work with
:param direction:
:return:
"""
if direction not in ["asc", "desc"]:
raise Exception(f"Unknown direction: {direction}")
dir = desc if direction == "desc" else asc
results = (
session.query(
Publisher.name, func.count(Author.fname).label("total_authors")
)
.join(Publisher.authors)
.group_by(Publisher.name)
.order_by(dir("total_authors"))
)
return results
def get_authors(session) -> List:
"""
This function returns a list of author objects
:param session: database session to work with
:return: list of Author objects
"""
results = session.query(Author).order_by(Author.lname).all()
return results
def add_new_book(session, author_name, book_title, publisher_name):
"""
This function adds a new book to the database
:param session: database session to work with
:param author_name: authors full name
:param book_title: book title
:param publisher_name: publisher of book
:return: None
"""
fname, lname = author_name.split(" ")
# Does the book exist?
book = session.query(Book).filter(Book.title == book_title).one_or_none()
if book is not None:
raise Exception("Book exists", book_title)
# Get author
author = (
session.query(Author)
.filter(and_(Author.fname == fname, Author.lname == lname))
.one_or_none()
)
# Did we get an author?
if author is None:
raise Exception("No author found", author_name)
# Get publisher
publisher = (
session.query(Publisher)
.filter(Publisher.name == publisher_name)
.one_or_none()
)
# Did we get a publisher?
if publisher is None:
raise Exception("No publisher found", publisher)
# Create the book
new_book = Book(title=book_title)
# Insert the book and create the relationships
author.books.append(new_book)
publisher.books.append(new_book)
session.commit()
def output_hierarchical_author_data(authors):
"""
This function outputs the author/book/publisher information in
a hierarchical manner
:param authors: the collection of root author objects
:return: None
"""
authors_tree = Tree()
authors_tree.create_node("Authors", "authors")
for author in authors:
authors_tree.create_node(
f"{author.fname} {author.lname}",
f"{author.fname} {author.lname}",
parent="authors",
)
for book in author.books:
authors_tree.create_node(
f"{book.title}",
f"{book.title}",
parent=f"{author.fname} {author.lname}",
)
for publisher in book.publishers:
authors_tree.create_node(
f"{publisher.name}", uuid4(), parent=f"{book.title}"
)
# Output the hierarchical authors data
print(authors_tree.show())
def main():
"""
Main entry point of program
"""
print("starting")
# Connect to the database using SqlAlchemy
sqlite_filepath = resource_filename(
"project.data", "author_book_publisher.db"
)
engine = create_engine(f"sqlite:///{sqlite_filepath}")
Session = sessionmaker()
Session.configure(bind=engine)
session = Session()
# Get the total number of books printed by each publisher
total_books_by_publisher = get_total_number_of_books_by_publishers(
session, "desc"
)
for row in total_books_by_publisher:
print(f"Publisher: {row.name}, total books: {row.total_books}")
print()
# Get the total number of authors each publisher publishes
total_authors_by_publisher = get_total_number_of_authors_by_publishers(
session, "desc"
)
for row in total_authors_by_publisher:
print(f"Publisher: {row.name}, total authors: {row.total_authors}")
print()
# Output hierarchical authors data
authors = get_authors(session)
output_hierarchical_author_data(authors)
# Add a new book
add_new_book(
session,
author_name="Stephen King",
book_title="The Stand",
publisher_name="Random House",
)
# Output the updated hierarchical authors data
authors = get_authors(session)
output_hierarchical_author_data(authors)
print("finished")
if __name__ == "__main__":
main()
......@@ -4,6 +4,7 @@ from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
author_publisher = Table(
"author_publisher",
Base.metadata,
......@@ -11,6 +12,7 @@ author_publisher = Table(
Column("publisher_id", Integer, ForeignKey("publisher.publisher_id")),
)
book_publisher = Table(
"book_publisher",
Base.metadata,
......@@ -22,8 +24,8 @@ book_publisher = Table(
class Author(Base):
__tablename__ = "author"
author_id = Column(Integer, primary_key=True)
fname = Column(String)
lname = Column(String)
first_name = Column(String)
last_name = Column(String)
books = relationship("Book", backref=backref("author"))
publishers = relationship(
"Publisher", secondary=author_publisher, back_populates="authors"
......
[metadata]
name = local_project
version = 0.1.0
[options]
packages = structure
\ No newline at end of file
......@@ -4,5 +4,16 @@ setup(
name="project",
version="1.0",
packages=find_packages(),
install_requires=["SQLAlchemy", "treelib"],
install_requires=[
"pandas==1.0.3",
"Flask==1.1.1",
"SQLAlchemy==1.3.13",
"Flask-SQLAlchemy==2.4.1",
"Flask-Cors==3.0.8",
"Flask-Bootstrap4==4.0.2",
"Flask-WTF==0.14.3",
"python-dateutil==2.8.1",
"python-dotenv==0.10.5",
"treelib",
],
)
......@@ -85,12 +85,12 @@ class CIFAR_Image:
def store_single_disk(image, image_id, label):
""" Stores a single image as a .png file on disk.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""Stores a single image as a .png file on disk.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""
Image.fromarray(image).save(disk_dir / f"{image_id}.png")
......@@ -102,12 +102,12 @@ def store_single_disk(image, image_id, label):
def store_single_lmdb(image, image_id, label):
""" Stores a single image to a LMDB.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""Stores a single image to a LMDB.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""
map_size = image.nbytes * 10
......@@ -125,12 +125,12 @@ def store_single_lmdb(image, image_id, label):
def store_single_hdf5(image, image_id, label):
""" Stores a single image to an HDF5 file.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""Stores a single image to an HDF5 file.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""
# Create a new HDF5 file
......@@ -164,11 +164,11 @@ for method in ("disk", "lmdb", "hdf5"):
def store_many_disk(images, labels):
""" Stores an array of images to disk
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""Stores an array of images to disk
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""
num_images = len(images)
......@@ -188,11 +188,11 @@ def store_many_disk(images, labels):
def store_many_lmdb(images, labels):
""" Stores an array of images to LMDB.
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""Stores an array of images to LMDB.
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""
num_images = len(images)
......@@ -212,11 +212,11 @@ def store_many_lmdb(images, labels):
def store_many_hdf5(images, labels):
""" Stores an array of images to HDF5.
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""Stores an array of images to HDF5.
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""
num_images = len(images)
......@@ -270,14 +270,14 @@ for cutoff in cutoffs:
def plot_with_legend(
x_range, y_data, legend_labels, x_label, y_label, title, log=False
):
""" Displays a single plot with multiple datasets and matching legends.
Parameters:
--------------
x_range list of lists containing x data
y_data list of lists containing y values
legend_labels list of string legend labels
x_label x axis label
y_label y axis label
"""Displays a single plot with multiple datasets and matching legends.
Parameters:
--------------
x_range list of lists containing x data
y_data list of lists containing y values
legend_labels list of string legend labels
x_label x axis label
y_label y axis label
"""
plt.style.use("seaborn-whitegrid")
plt.figure(figsize=(10, 7))
......@@ -362,15 +362,15 @@ plt.show()
def read_single_disk(image_id):
""" Stores a single image to disk.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""Stores a single image to disk.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""
image = np.array(Image.open(disk_dir / f"{image_id}.png"))
......@@ -384,15 +384,15 @@ def read_single_disk(image_id):
def read_single_lmdb(image_id):
""" Stores a single image to LMDB.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""Stores a single image to LMDB.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""
# Open the LMDB environment; see (1)
......@@ -413,15 +413,15 @@ def read_single_lmdb(image_id):
def read_single_hdf5(image_id):
""" Stores a single image to HDF5.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""Stores a single image to HDF5.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""
# Open the HDF5 file
......@@ -454,15 +454,15 @@ for method in ("disk", "lmdb", "hdf5"):
def read_many_disk(num_images):
""" Reads image from disk.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""Reads image from disk.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""
images, labels = [], []
......@@ -480,15 +480,15 @@ def read_many_disk(num_images):
def read_many_lmdb(num_images):
""" Reads image from LMDB.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""Reads image from LMDB.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""
images, labels = [], []
env = lmdb.open(str(lmdb_dir / f"{num_images}_lmdb"), readonly=True)
......@@ -509,15 +509,15 @@ def read_many_lmdb(num_images):
def read_many_hdf5(num_images):
""" Reads image from HDF5.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""Reads image from HDF5.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""
images, labels = [], []
......
# Build a Web Scraper With Requests and Beautiful Soup
This repository contains code relating to the Real Python tutorial on how to [Build a Web Scraper With Requests and Beautiful Soup](https://realpython.com/build-web-scraper-with-requests-beautiful-soup/).
This repository contains code relating to the Real Python tutorial on how to [Build a Web Scraper With Requests and Beautiful Soup](https://realpython.com/beautiful-soup-web-scraper-python/).
There are two available scripts:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册