демо релиз

This commit is contained in:
za_litvu 2025-04-04 03:35:58 +07:00
parent 02217be44e
commit 606cd400a0
358 changed files with 3183 additions and 6184 deletions

View File

@ -9,7 +9,7 @@ services:
- postgres_data:/var/lib/postgresql/data
web:
build: ./service/zircon_web
build: ./web
ports:
- "8000:8000"
depends_on:

View File

@ -1 +0,0 @@
# в данном каталоге содержатся инструменты для управления докером

View File

@ -1,247 +0,0 @@
<#
.Synopsis
Activate a Python virtual environment for the current PowerShell session.
.Description
Pushes the python executable for a virtual environment to the front of the
$Env:PATH environment variable and sets the prompt to signify that you are
in a Python virtual environment. Makes use of the command line switches as
well as the `pyvenv.cfg` file values present in the virtual environment.
.Parameter VenvDir
Path to the directory that contains the virtual environment to activate. The
default value for this is the parent of the directory that the Activate.ps1
script is located within.
.Parameter Prompt
The prompt prefix to display when this virtual environment is activated. By
default, this prompt is the name of the virtual environment folder (VenvDir)
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
.Example
Activate.ps1
Activates the Python virtual environment that contains the Activate.ps1 script.
.Example
Activate.ps1 -Verbose
Activates the Python virtual environment that contains the Activate.ps1 script,
and shows extra information about the activation as it executes.
.Example
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
Activates the Python virtual environment located in the specified location.
.Example
Activate.ps1 -Prompt "MyPython"
Activates the Python virtual environment that contains the Activate.ps1 script,
and prefixes the current prompt with the specified string (surrounded in
parentheses) while the virtual environment is active.
.Notes
On Windows, it may be required to enable this Activate.ps1 script by setting the
execution policy for the user. You can do this by issuing the following PowerShell
command:
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
For more information on Execution Policies:
https://go.microsoft.com/fwlink/?LinkID=135170
#>
Param(
[Parameter(Mandatory = $false)]
[String]
$VenvDir,
[Parameter(Mandatory = $false)]
[String]
$Prompt
)
<# Function declarations --------------------------------------------------- #>
<#
.Synopsis
Remove all shell session elements added by the Activate script, including the
addition of the virtual environment's Python executable from the beginning of
the PATH variable.
.Parameter NonDestructive
If present, do not remove this function from the global namespace for the
session.
#>
function global:deactivate ([switch]$NonDestructive) {
# Revert to original values
# The prior prompt:
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
}
# The prior PYTHONHOME:
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
}
# The prior PATH:
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
}
# Just remove the VIRTUAL_ENV altogether:
if (Test-Path -Path Env:VIRTUAL_ENV) {
Remove-Item -Path env:VIRTUAL_ENV
}
# Just remove VIRTUAL_ENV_PROMPT altogether.
if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
Remove-Item -Path env:VIRTUAL_ENV_PROMPT
}
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
}
# Leave deactivate function in the global namespace if requested:
if (-not $NonDestructive) {
Remove-Item -Path function:deactivate
}
}
<#
.Description
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
given folder, and returns them in a map.
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
two strings separated by `=` (with any amount of whitespace surrounding the =)
then it is considered a `key = value` line. The left hand string is the key,
the right hand is the value.
If the value starts with a `'` or a `"` then the first and last character is
stripped from the value before being captured.
.Parameter ConfigDir
Path to the directory that contains the `pyvenv.cfg` file.
#>
function Get-PyVenvConfig(
[String]
$ConfigDir
) {
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
# An empty map will be returned if no config file is found.
$pyvenvConfig = @{ }
if ($pyvenvConfigPath) {
Write-Verbose "File exists, parse `key = value` lines"
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
$pyvenvConfigContent | ForEach-Object {
$keyval = $PSItem -split "\s*=\s*", 2
if ($keyval[0] -and $keyval[1]) {
$val = $keyval[1]
# Remove extraneous quotations around a string value.
if ("'""".Contains($val.Substring(0, 1))) {
$val = $val.Substring(1, $val.Length - 2)
}
$pyvenvConfig[$keyval[0]] = $val
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
}
}
}
return $pyvenvConfig
}
<# Begin Activate script --------------------------------------------------- #>
# Determine the containing directory of this script
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
$VenvExecDir = Get-Item -Path $VenvExecPath
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
# Set values required in priority: CmdLine, ConfigFile, Default
# First, get the location of the virtual environment, it might not be
# VenvExecDir if specified on the command line.
if ($VenvDir) {
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
}
else {
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
Write-Verbose "VenvDir=$VenvDir"
}
# Next, read the `pyvenv.cfg` file to determine any required value such
# as `prompt`.
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
# Next, set the prompt from the command line, or the config file, or
# just use the name of the virtual environment folder.
if ($Prompt) {
Write-Verbose "Prompt specified as argument, using '$Prompt'"
}
else {
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
$Prompt = $pyvenvCfg['prompt'];
}
else {
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
$Prompt = Split-Path -Path $venvDir -Leaf
}
}
Write-Verbose "Prompt = '$Prompt'"
Write-Verbose "VenvDir='$VenvDir'"
# Deactivate any currently active virtual environment, but leave the
# deactivate function in place.
deactivate -nondestructive
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
# that there is an activated venv.
$env:VIRTUAL_ENV = $VenvDir
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
Write-Verbose "Setting prompt to '$Prompt'"
# Set the prompt to include the env name
# Make sure _OLD_VIRTUAL_PROMPT is global
function global:_OLD_VIRTUAL_PROMPT { "" }
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
function global:prompt {
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
_OLD_VIRTUAL_PROMPT
}
$env:VIRTUAL_ENV_PROMPT = $Prompt
}
# Clear PYTHONHOME
if (Test-Path -Path Env:PYTHONHOME) {
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
Remove-Item -Path Env:PYTHONHOME
}
# Add the venv to the PATH
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"

View File

@ -1,70 +0,0 @@
# This file must be used with "source bin/activate" *from bash*
# You cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# Call hash to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
hash -r 2> /dev/null
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
unset VIRTUAL_ENV_PROMPT
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
# on Windows, a path can contain colons and backslashes and has to be converted:
if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
# transform D:\path\to\venv to /d/path/to/venv on MSYS
# and to /cygdrive/d/path/to/venv on Cygwin
export VIRTUAL_ENV=$(cygpath /home/efim/project/zircon/docker/python_docker_libs)
else
# use the path as-is
export VIRTUAL_ENV=/home/efim/project/zircon/docker/python_docker_libs
fi
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/"bin":$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "${PYTHONHOME:-}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1='(python_docker_libs) '"${PS1:-}"
export PS1
VIRTUAL_ENV_PROMPT='(python_docker_libs) '
export VIRTUAL_ENV_PROMPT
fi
# Call hash to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
hash -r 2> /dev/null

View File

@ -1,27 +0,0 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
# Unset irrelevant variables.
deactivate nondestructive
setenv VIRTUAL_ENV /home/efim/project/zircon/docker/python_docker_libs
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/"bin":$PATH"
set _OLD_VIRTUAL_PROMPT="$prompt"
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
set prompt = '(python_docker_libs) '"$prompt"
setenv VIRTUAL_ENV_PROMPT '(python_docker_libs) '
endif
alias pydoc python -m pydoc
rehash

View File

@ -1,69 +0,0 @@
# This file must be used with "source <venv>/bin/activate.fish" *from fish*
# (https://fishshell.com/). You cannot run it directly.
function deactivate -d "Exit virtual environment and return to normal shell environment"
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
set -e _OLD_FISH_PROMPT_OVERRIDE
# prevents error when using nested fish instances (Issue #93858)
if functions -q _old_fish_prompt
functions -e fish_prompt
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
end
end
set -e VIRTUAL_ENV
set -e VIRTUAL_ENV_PROMPT
if test "$argv[1]" != "nondestructive"
# Self-destruct!
functions -e deactivate
end
end
# Unset irrelevant variables.
deactivate nondestructive
set -gx VIRTUAL_ENV /home/efim/project/zircon/docker/python_docker_libs
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/"bin $PATH
# Unset PYTHONHOME if set.
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish uses a function instead of an env var to generate the prompt.
# Save the current fish_prompt function as the function _old_fish_prompt.
functions -c fish_prompt _old_fish_prompt
# With the original prompt function renamed, we can override with our own.
function fish_prompt
# Save the return status of the last command.
set -l old_status $status
# Output the venv prompt; color taken from the blue of the Python logo.
printf "%s%s%s" (set_color 4B8BBE) '(python_docker_libs) ' (set_color normal)
# Restore the return status of the previous command.
echo "exit $old_status" | .
# Output the original/"old" prompt.
_old_fish_prompt
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
set -gx VIRTUAL_ENV_PROMPT '(python_docker_libs) '
end

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/docker/python_docker_libs/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from charset_normalizer import cli
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(cli.cli_detect())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/docker/python_docker_libs/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/docker/python_docker_libs/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/docker/python_docker_libs/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1 +0,0 @@
python3

View File

@ -1 +0,0 @@
/usr/bin/python3

View File

@ -1 +0,0 @@
python3

View File

@ -1 +0,0 @@
lib

View File

@ -1,5 +0,0 @@
home = /usr/bin
include-system-site-packages = false
version = 3.12.3
executable = /usr/bin/python3.12
command = /home/efim/project/zircon/docker/python_docker_libs/bin/python3 -m venv /home/efim/project/zircon/docker/python_docker_libs

View File

@ -1,47 +0,0 @@
import os
from io import BytesIO
import docker
def get_path(service_folder):
parent_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir))
service_dir = os.path.join(parent_dir, service_folder)
if not os.path.exists(service_dir):
raise FileNotFoundError(f"Папка 'service_dir' не существует.")
return service_dir
def get_requirements_service(service_folder):
# Рекурсивно сканируем все подпапки в папке service
requirements_service = []
for root, dirs, files in os.walk(service_folder):
if 'requirements.txt' in files:
root_service, service_name = root.split('/')[-2:]
requirements_path = os.path.join(root, 'requirements.txt')
requirements_service.append({'root_service':root_service,
'service_name':service_name,
'requirements_path':requirements_path,
'root':root})
return requirements_service
def build_requirements_image(requirements_path, container_name, root):
client = docker.from_env()
with open('./template/requirements.dockerfile', 'r', encoding='utf-8') as file:
docker_template = file.read()
docker_images = docker_template.format(requirements_path)
dockerfile = BytesIO(docker_images.encode('utf-8'))
print(requirements_path)
print(root)
image, logs = client.images.build(fileobj=dockerfile, tag='my_dynamic_app:latest', path=root)
return image, logs
if __name__=='__main__':
path_folder = get_path('service')
requirements_service = get_requirements_service(path_folder)
for service in requirements_service:
image, logs = build_requirements_image(service['requirements_path'],
f'requirements_{service['root_service']}_{service['service_name']}',
service['root'] )
for log in logs:
print(log.get('stream', ''))
print(f'Образ {image.tags[0]} успешно создан.')

View File

@ -1,6 +0,0 @@
FROM python:3.9-slim
COPY {} $APP_HOME
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /wheels -r requirements.txt
RUN pip install --no-cache /wheels/* && rm -rf /wheels

View File

@ -1,28 +0,0 @@
import cv2
import uvicorn
from fastapi import FastAPI
from starlette.responses import StreamingResponse
import time
app = FastAPI()
def generate_video():
cap = cv2.VideoCapture('IMG_3995.MOV')
while True:
success, frame = cap.read()
if not success:
break
frame = cv2.resize(frame, (650, 480))
_, buffer = cv2.imencode(".jpg", frame)
yield (b"--frame\r\n"
b"Content-Type: image/jpeg\r\n\r\n" + buffer.tobytes() + b"\r\n")
time.sleep(0.1)
@app.get("/video_feed")
def video_feed():
return StreamingResponse(generate_video(), media_type="multipart/x-mixed-replace; boundary=frame")
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8008)

View File

@ -1,51 +0,0 @@
from django.contrib import admin
from .models import MachineEvent, WorkPeriod, Document, Machine, Camera, Server, WorkShift
@admin.register(MachineEvent)
class SystemEventAdmin(admin.ModelAdmin):
list_display = ('machine', 'status', 'timestamp') # Поля, отображаемые в списке
list_filter = ('status', 'timestamp') # Фильтры справа
search_fields = ('machine__name', 'status') # Поиск по связанным полям
ordering = ('-timestamp',) # Сортировка по умолчанию (новые события сверху)
date_hierarchy = 'timestamp' # Иерархия по дате
@admin.register(WorkPeriod)
class WorkPeriodAdmin(admin.ModelAdmin):
list_display = ('machine', 'status', 'start_time', 'end_time', 'reason') # Поля, отображаемые в списке
list_filter = ('status', 'start_time', 'end_time') # Фильтры справа
search_fields = ('machine__name', 'status', 'reason') # Поиск по связанным полям
ordering = ('-start_time',) # Сортировка по умолчанию (новые периоды сверху)
date_hierarchy = 'start_time' # Иерархия по дате
fieldsets = (
(None, {
'fields': ('machine', 'status', 'start_time', 'end_time')
}),
('Причина', {
'fields': ('reason',),
'classes': ('collapse',) # Сворачиваемый блок
}),
)
admin.site.register(Document)
admin.site.register(Server)
admin.site.register(WorkShift)
@admin.register(Machine)
class MachineAdmin(admin.ModelAdmin):
list_display = ('name', 'device_id')
@admin.register(Camera)
class CameraAdmin(admin.ModelAdmin):
list_display = ('machine', 'rtsp', 'id') # Поля, отображаемые в списке
list_filter = ('machine',) # Фильтры справа
search_fields = ('machine__name',) # Поиск по связанным полям
ordering = ('machine',) # Сортировка по умолчанию
fieldsets = (
(None, {
'fields': ('machine',)
}),
('RTSP', {
'fields': ('rtsp',)
}),
)

View File

@ -1,39 +0,0 @@
import requests
import json
import time
import random
url = "http://192.168.31.56:8008/new_events/"
headers = {
'Authorization': 'a213dc3f-d8f5-4333-9f53-ef56dea1ac87',
'Content-Type': 'application/json',
}
payload = json.dumps({
"event": {
"camera": 1,
"timestamp": 2424,
"status": 1
}
})
while True:
# Выбираем случайный промежуток времени (от 5 секунд)
duration = random.randint(30, 1000) # Например, от 5 до 15 секунд
# Выбираем случайный статус
status = random.randint(0, 1)
print(f"Новый статус: {status}, продолжительность: {duration} секунд")
# Отправляем один и тот же статус в течение выбранного промежутка времени
start_time = time.time()
while time.time() - start_time < duration:
payload = json.dumps({
"event": {
"camera": 1,
"timestamp": int(time.time()), # Текущее время в секундах
"status": status
}
})
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
time.sleep(0.5)

View File

@ -1,51 +0,0 @@
.container_table {
width: 600px;
border: 1px solid #ccc;
border-radius: 8px;
margin: 10px;
padding: 10px;
background: white;
}
.header_table {
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
padding: 10px;
background: #f0f0f0;
border-radius: 8px;
}
.content_table {
max-height: 200px;
overflow-y: auto;
display: none;
margin-top: 10px;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 8px;
border-bottom: 1px solid #ddd;
}
tr:hover {
background-color: #f1f1f1;
cursor: pointer;
}
.icon {
font-size: 20px;
transition: transform 0.3s;
margin-left: 10px;
}
.expanded .icon {
transform: rotate(180deg);
}

View File

@ -1,81 +0,0 @@
body {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
background-color: #F4F5F6;
}
.main-header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #DAE6FF;
color: #0A5BFF;
padding: 15px 30px;
border-radius: 15px;
margin: 20px;
text-align: center;
/* max-width: 1300px; */
}
.content {
max-height: 10000px;
overflow-y: auto;
}
.top-nav a {
color: white;
text-decoration: none;
margin-left: 15px;
}
.wrapper {
width: 100%;
height: 100%;
display: flex;
flex-grow: 1;
/* margin-top: 20px; */
gap: 20px;
}
.sidebar {
width: 250px;
background-color: #FFFFFF;
padding-top: 20px;
transition: width 0.3s ease;
overflow: hidden;
border-radius: 15px;
margin-left: 20px;
}
.sidebar a {
display: block;
color: #8A8894;
padding: 10px;
text-decoration: none;
white-space: nowrap;
}
.sidebar a:hover {
background-color: #DAE6FF;
}
.sidebar.collapsed {
width: 60px;
}
.sidebar.collapsed a {
text-align: 60px;
}
.toggle-btn{
background-color: #DAE6FF;
border-radius: 6px;
}
.logout-button{
background-color: #DAE6FF;
border: none;
}

File diff suppressed because one or more lines are too long

View File

@ -1,93 +0,0 @@
/* ckeditor.css */
.ck-editor__editable {
min-height: 300px;
border: 1px solid #e0e0e0;
border-radius: 4px;
padding: 15px;
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.ck-toolbar {
border: 1px solid #e0e0e0;
border-radius: 4px 4px 0 0;
background-color: #f5f5f5;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.ck-button {
color: #333;
border-radius: 4px;
transition: background-color 0.2s;
}
.ck-button:hover {
background-color: #e0e0e0;
}
.ck-dropdown__panel {
border: 1px solid #e0e0e0;
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.ck-dropdown__panel .ck-button {
padding: 8px 12px;
}
.ck-dropdown__panel .ck-button:hover {
background-color: #f0f0f0;
}
.ck-content h1, .ck-content h2, .ck-content h3 {
color: #333;
font-weight: bold;
}
.ck-content p {
color: #555;
line-height: 1.6;
}
.ck-content a {
color: #007bff;
text-decoration: none;
}
.ck-content a:hover {
text-decoration: underline;
}
/* ckeditor.css */
.ck-content code {
background-color: #f5f5f5;
padding: 2px 4px;
border-radius: 3px;
font-family: "Courier New", monospace;
}
.ck-content table {
width: 100%;
border-collapse: collapse;
margin: 10px 0;
background-color: #333;
}
.ck-content table td, .ck-content table th {
border: 1px solid #ddd;
padding: 8px;
}
.ck-content table th {
background-color: #f5f5f5;
font-weight: bold;
}
.ck-content .todo-list li {
list-style-type: none;
margin-left: 0;
}
.ck-content .todo-list li input[type="checkbox"] {
margin-right: 8px;
}

View File

@ -1,129 +0,0 @@
:root {
--primary: #6366f1;
--primary-hover: #4f46e5;
--background: #f8fafc;
--text: #0f172a;
--gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', system-ui, sans-serif;
}
body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: var(--background);
padding: 1rem;
line-height: 1.5;
color: var(--text);
}
.error-container {
text-align: center;
max-width: 600px;
padding: 2rem;
background: white;
border-radius: 1.5rem;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
position: relative;
overflow: hidden;
}
.error-container::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 8px;
background: var(--gradient);
}
.error-graphic {
width: 200px;
height: 200px;
margin: 0 auto 2rem;
position: relative;
animation: float 3s ease-in-out infinite;
}
.error-code {
font-size: 4rem;
font-weight: 800;
background: var(--gradient);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
margin-bottom: 0.5rem;
}
h1 {
font-size: 1.875rem;
margin-bottom: 1rem;
color: var(--text);
}
.error-message {
color: #64748b;
margin-bottom: 2rem;
}
.actions {
display: flex;
gap: 1rem;
justify-content: center;
}
.btn {
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
font-weight: 500;
transition: all 0.2s;
text-decoration: none;
display: inline-flex;
align-items: center;
gap: 0.5rem;
}
.btn-primary {
background: var(--primary);
color: white;
border: 2px solid var(--primary);
}
.btn-primary:hover {
background: var(--primary-hover);
transform: translateY(-2px);
}
.btn-secondary {
border: 2px solid #e2e8f0;
color: var(--text);
background: white;
}
.btn-secondary:hover {
border-color: #cbd5e1;
background: #f8fafc;
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-20px); }
}
@media (max-width: 640px) {
.error-code {
font-size: 3rem;
}
h1 {
font-size: 1.5rem;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

File diff suppressed because one or more lines are too long

View File

@ -1,104 +0,0 @@
document.addEventListener('DOMContentLoaded', function () {
"use strict"; // Строгий режим
console.log("DOM загружен"); // Отладочное сообщение
// Инициализация Scrollspy
let scrollSpy = new bootstrap.ScrollSpy(document.body, {
target: '#page-nav',
smoothScroll: true
});
// Кнопка для мобильной навигации
const toggleNavButton = document.getElementById('toggle-nav');
const leftNav = document.getElementById('left-nav');
const rightNav = document.getElementById('right-nav');
console.log("toggleNavButton:", toggleNavButton); // Отладочное сообщение
console.log("leftNav:", leftNav); // Отладочное сообщение
console.log("rightNav:", rightNav); // Отладочное сообщение
if (toggleNavButton && leftNav && rightNav) {
toggleNavButton.addEventListener('click', function () {
console.log("Кнопка нажата"); // Отладочное сообщение
if (leftNav.classList.contains('d-none')) {
leftNav.classList.remove('d-none');
rightNav.classList.remove('d-none');
this.textContent = 'Скрыть навигацию';
} else {
leftNav.classList.add('d-none');
rightNav.classList.add('d-none');
this.textContent = 'Показать навигацию';
}
});
} else {
console.error("Один из элементов не найден"); // Отладочное сообщение
}
// Поиск по странице
const searchForm = document.getElementById('search-form');
const searchInput = document.getElementById('search-input');
if (searchForm && searchInput) {
searchForm.addEventListener('submit', function (event) {
event.preventDefault(); // Отменяем стандартное поведение формы
const searchQuery = searchInput.value.trim();
if (searchQuery === '') {
alert('Введите текст для поиска.');
return;
}
// Очищаем предыдущие выделения
clearHighlights();
// Ищем и выделяем текст
const pageContents = document.querySelectorAll('.page-content');
let found = false;
let firstHighlight = null; // Первое найденное выделение
pageContents.forEach(page => {
const contentElements = page.querySelectorAll('.content p'); // Ищем текст внутри <p>
contentElements.forEach(element => {
const text = element.textContent;
const regex = new RegExp(`(${searchQuery})`, 'gi'); // Регулярное выражение для поиска
const newText = text.replace(regex, '<span class="highlight">$1</span>'); // Заменяем найденное слово на выделенный текст
if (newText !== text) {
element.innerHTML = newText; // Обновляем содержимое элемента
found = true;
// Если это первое найденное выделение, сохраняем его
if (!firstHighlight) {
firstHighlight = element.querySelector('.highlight');
}
}
});
});
// Прокрутка к первому найденному выделению
if (firstHighlight) {
firstHighlight.scrollIntoView({
behavior: 'smooth', // Плавная прокрутка
block: 'center' // Прокрутка к центру экрана
});
}
if (!found) {
alert('Ничего не найдено.');
}
});
// Функция для очистки выделений
function clearHighlights() {
const highlights = document.querySelectorAll('.highlight');
highlights.forEach(highlight => {
const text = highlight.textContent;
highlight.replaceWith(text); // Убираем выделение
});
}
} else {
console.error("Форма поиска или поле ввода не найдены"); // Отладочное сообщение
}
});

File diff suppressed because one or more lines are too long

View File

@ -1,60 +0,0 @@
/* Стили для модального окна */
#modal {
border: none;
border-radius: 10px;
padding: 20px;
width: 300px;
}
/* Заголовок модального окна */
.modal-header {
font-size: 18px;
font-weight: bold;
margin-bottom: 10px;
}
/* Метка */
.modal-label {
display: block;
font-size: 14px;
opacity: 0.6;
margin-bottom: 5px;
}
/* Поле ввода */
.modal-textarea {
width: 100%;
height: 80px;
border-radius: 8px;
border: 1px solid #ccc;
padding: 8px;
resize: none;
}
/* Подвал модального окна */
.modal-footer {
display: flex;
justify-content: space-between;
margin-top: 15px;
}
/* Общие стили для кнопок */
.modal-button {
border: none;
font-size: 14px;
cursor: pointer;
border-radius: 6px;
padding: 8px 12px;
}
/* Кнопка "Закрыть" */
.modal-button.close {
background: transparent;
color: #007bff;
}
/* Кнопка "Отправить" */
.modal-button.submit {
background-color: #007bff;
color: white;
}

View File

@ -1,112 +0,0 @@
canvas {
width: 100% !important;
height: 100% !important;
}
.title-box {
background: #DAE6FF;
/* padding: 15px 30px; */
border-radius: 10px;
color: #0A5BFF;
font-size: 48px;
font-weight: bold;
text-align: center;
max-width: 1000px;
width: 100%;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.main-container {
background-color: #F4F5F6;
display: flex;
/* flex-direction: column; */
gap: 20px;
width: 100%;
}
.left-panel {
flex: 2;
background: #FFFFFF;
border-radius: 10px;
padding: 20px;
height: 500px;
min-width: 600px;
max-width: 700px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.right-panel {
flex: 1;
display: flex;
flex-direction: column;
gap: 20px;
max-width: 300px;
}
.left-panel, .right-panel {
overflow: hidden;
overflow: auto;
}
.small-box {
background: #FFFFFF;
border-radius: 10px;
padding: 20px;
height: 200px;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.button-box {
background: #0A5BFF;
color: white;
text-align: center;
border-radius: 10px;
padding: 15px;
cursor: pointer;
}
.button-box:hover{
background: #0952E6;
}
.label-container {
display: flex;
align-items: center;
gap: 10px;
}
.label-box {
background: #C5CCD4;
padding: 5px;
border-radius: 5px;
}
.report-box {
background: white;
display: flex;
border-radius: 10px;
}
.input-container {
display: flex;
flex-direction: column;
align-items: left;
gap: 1px;
}
.modal-header {
font-size: 18px;
font-weight: bold;
margin-bottom: 10px;
}
.modal-body {
display: flex;
flex-direction: column;
gap: 10px;
}
.modal-footer {
margin-top: 15px;
text-align: right;
}
.modal-footer button {
padding: 8px 15px;
cursor: pointer;
}

View File

@ -1,322 +0,0 @@
/* Глобальные переменные */
:root {
--primary-color: #0d6efd;
--secondary-color: #6c757d;
--background-color: #f8f9fa;
--border-color: #dee2e6;
--text-color: #333;
--shadow-color: rgba(0, 0, 0, 0.1);
--gradient-primary: linear-gradient(135deg, #0d6efd, #0b5ed7);
--gradient-hover: linear-gradient(135deg, #0b5ed7, #0a58ca);
--navbar-height: 10px; /* Высота навбара */
--content-padding: 10px; /* Стандартный отступ для контента */
}
/* Глобальные стили для body */
body {
font-family: Arial, sans-serif;
color: var(--text-color);
background-color: var(--background-color);
/*padding: var(--navbar-height);*/
/*margin: 0;*/
}
.navbar-brand {
display: flex;
align-items: center;
font-size: 1.25rem;
font-weight: bold;
color: var(--primary-color) !important;
transition: opacity 0.3s;
}
.navbar-brand:hover {
opacity: 0.8;
}
.navbar-brand img {
border-radius: 8px;
transition: transform 0.3s;
}
.navbar-brand:hover img {
transform: scale(1.1);
}
/* Стили для кнопки выхода */
.btn-outline-danger {
border: 2px solid;
font-weight: 500;
transition: all 0.3s;
display: flex;
align-items: center;
}
.btn-outline-danger:hover {
background-color: #dc3545;
color: white !important;
transform: translateY(-2px);
}
.btn-outline-danger i {
margin-right: 8px;
}
/* Анимации */
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Адаптивность */
@media (max-width: 768px) {
.navbar-brand {
font-size: 1rem;
}
.btn-outline-danger {
padding: 5px 10px;
font-size: 0.9rem;
}
.footer .text-muted {
font-size: 0.8rem;
}
}
/* Стили для карточек книг */
.card {
border: none;
border-radius: 12px;
overflow: hidden;
background-color: white;
box-shadow: 0 4px 12px var(--shadow-color);
transition: transform 0.3s, box-shadow 0.3s;
height: 100%;
display: flex;
flex-direction: column;
scroll-margin-bottom: 100px;
}
.card-img-overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 1rem;
display: flex;
justify-content: flex-end;
align-items: flex-start;
pointer-events: none; /* Позволяет кликать через иконки на карточке */
}
.card-img-overlay a {
pointer-events: auto; /* Возвращает возможность кликать по иконкам */
}
.card-img-overlay a i {
background-color: rgba(255, 255, 255, 0.7);
border-radius: 50%;
padding: 0.3rem;
margin-left: 0.5rem;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 16px rgba(13, 110, 253, 0.3), 0 12px 24px rgba(13, 110, 253, 0.2) !important;
}
.card-img-top {
height: 200px;
object-fit: cover;
border-bottom: 1px solid var(--border-color);
}
.card-body {
padding: 20px;
flex-grow: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.card-title {
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 10px;
color: var(--text-color);
}
.card-text {
font-size: 0.9rem;
color: var(--secondary-color);
margin-bottom: 15px;
}
.card-link {
text-decoration: none;
color: inherit;
}
/* Стили для карточки "Добавить книгу" */
.card-add {
background-color: var(--background-color);
border: 2px dashed var(--border-color);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.card-add:hover {
background-color: #e9ecef;
border-color: var(--primary-color);
box-shadow: 0 8px 16px rgba(13, 110, 253, 0.3), 0 12px 24px rgba(13, 110, 253, 0.2); /* Синие тени */
}
.card-add .card-body {
text-align: center;
}
.card-add i {
font-size: 2rem;
color: var(--primary-color);
margin-bottom: 10px;
}
.card-add h5 {
font-size: 1.1rem;
color: var(--primary-color);
margin: 0;
}
/* Стили для модального окна */
.modal-content {
border: none;
border-radius: 12px;
box-shadow: 0 4px 12px var(--shadow-color);
}
.modal-header {
background-color: var(--primary-color);
color: white;
border-top-left-radius: 12px;
border-top-right-radius: 12px;
padding: 15px 20px;
}
.modal-title {
font-size: 1.25rem;
font-weight: 600;
}
.modal-body {
padding: 20px;
}
.modal-footer {
border-top: 1px solid var(--border-color);
padding: 15px 20px;
}
/* Стили для формы */
.form-label {
font-weight: 500;
color: var(--text-color);
margin-bottom: 5px;
}
.form-control {
border: 1px solid var(--border-color);
border-radius: 8px;
padding: 10px;
font-size: 0.9rem;
transition: border-color 0.3s, box-shadow 0.3s;
}
.form-control:focus {
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}
.form-select {
border: 1px solid var(--border-color);
border-radius: 8px;
padding: 10px;
font-size: 0.9rem;
transition: border-color 0.3s, box-shadow 0.3s;
}
.form-select:focus {
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}
.form-check-input {
margin-top: 0.3rem;
}
.form-check-label {
font-size: 0.9rem;
color: var(--text-color);
}
/* Стили для кнопок */
.btn-primary {
background: var(--gradient-primary);
border: none;
border-radius: 8px;
padding: 10px 20px;
font-size: 0.9rem;
font-weight: 500;
color: white;
transition: all 0.3s;
}
.btn-primary:hover {
background: var(--gradient-hover);
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.btn-secondary {
background-color: var(--secondary-color);
border: none;
border-radius: 8px;
padding: 10px 20px;
font-size: 0.9rem;
font-weight: 500;
color: white;
transition: all 0.3s;
}
.btn-secondary:hover {
background-color: #5a6268;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
/* Стили для ошибок валидации */
.invalid-feedback {
font-size: 0.8rem;
color: #dc3545;
margin-top: 5px;
}
.is-invalid {
border-color: #dc3545 !important;
}
.is-invalid:focus {
box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25) !important;
}

View File

@ -1,55 +0,0 @@
{% load static %}
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Страница{% endblock %}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<link rel="stylesheet" href="{% static '/base.css' %}">
<link rel="stylesheet" href="{% static '/stats.css' %}">
</head>
<body>
<!-- Верхний заголовок -->
<header class="main-header">
<!-- Кнопка сворачивания -->
<button class="toggle-btn" id="toggle-btn">⇦</button>
<h1>Мониторинг системы</h1>
<nav class="top-nav">
{% if user.is_authenticated %}
<form action="{% url 'logout' %}" method="post">
{% csrf_token %}
<button type="submit" class="logout-button">Выйти</button>
</form>
{% else %}
<a href="{% url 'login' %}">Войти</a>
{% endif %}
</nav>
</header>
<div class="wrapper">
<!-- Сайдбар -->
<div class="sidebar" id="sidebar">
<a href="/stats">Видеомониторинг</a>
<a href="/reason/">Периоды простоя</a>
<a href="/report/">Отчеты</a>
<a href="/client_admin/">Администрирование</a>
</div>
<!-- Контент -->
<div class="content">
{% block content %}{% endblock %}
</div>
</div>
<script>
document.getElementById("toggle-btn").addEventListener("click", function () {
let sidebar = document.getElementById("sidebar");
sidebar.classList.toggle("collapsed");
this.textContent = sidebar.classList.contains("collapsed") ? "⇨" : "⇦";
});
</script>
</body>
</html>

View File

@ -1,51 +0,0 @@
{% extends "base.html" %}
{% load static %}
{% block title %}Администрирование{% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static '/admin_table.css' %}">
<div class="main-container">
<div class="left-panel">
{% for table in data %}
<div class="container_table">
<div class="header_table" onclick="toggleContent(this)">
<span>{{ table.name }}</span>
<div>
<!-- <a class="button" href="/admin/client_app/{{ add }}add/">Добавить</a> -->
<span class="icon">▼</span>
</div>
</div>
<div class="content_table">
<table>
<tr>
{% for field in table.fields %}
<th>{{ field }}</th>
{% endfor %}
</tr>
{% for values in table.model_values %}
<tr>
{% for value in values %}
<td>{{ value }}</td> <!-- Directly accessing field in dictionary -->
{% endfor %}
</tr>
{% endfor %}
</table>
</div>
</div>
{% endfor %}
</div>
</div>
<script>
function toggleContent(element) {
let container = element.closest('.container_table');
let content = container.querySelector('.content_table');
content.style.display = content.style.display === 'none' || content.style.display === '' ? 'block' : 'none';
container.classList.toggle('expanded');
}
function openDetail(model, id) {
window.location.href = `/${model}/${id}/`;
}
</script>
{% endblock %}

View File

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ model_name }} - Детали</title>
</head>
<body>
<h2>Детали объекта из {{ model_name }}</h2>
<ul>
{% for field, value in object.get_fields.items %}
<li><strong>{{ field }}:</strong> {{ value }}</li>
{% endfor %}
</ul>
<a href="/{{ model_name }}/">Назад</a>
</body>
</html>

View File

@ -1,45 +0,0 @@
{% extends "base.html" %}
{% block title %}Статистика оборудования{% endblock %}
{% block content %}
<div class="main-container">
<div class="left-panel">
<img id="stream" src="http://192.168.31.56:8008/video_feed" alt="RTSP-поток" style="width: 100%; height: auto;">
</div>
<div class="right-panel">
<div class="small-box">
<strong>Информация</strong>
<div class="label-container">
<span>Статус:</span>
<span class="label-box">Загрузка...</span>
</div>
<div class="label-container">
<span>Время работы:</span>
<span class="run_time">0ч. 0м. 0.с</span>
</div>
<div class="label-container">
<span>Время простоя:</span>
<span class="sleep_time">0ч. 0м. 0.с</span>
</div>
</div>
</div>
</div>
<script>
function updateStatus() {
fetch('/get_status/')
.then(response => response.json())
.then(data => {
let labelBox = document.querySelector(".label-box");
labelBox.textContent = data.value;
labelBox.style.backgroundColor = data.color;
document.querySelector(".run_time").textContent = data.run_time;
document.querySelector(".sleep_time").textContent = data.sleep_time;
})
.catch(error => console.error('Ошибка загрузки:', error));
}
setInterval(updateStatus, 2000);
document.addEventListener("DOMContentLoaded", updateStatus);
</script>
{% endblock %}

View File

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@ -1,176 +0,0 @@
from django.shortcuts import render, redirect
from django.http import HttpResponse
from django.http import JsonResponse
import time
import datetime
from django.utils import timezone
from django.contrib.auth.decorators import login_required
from django.contrib.auth.views import LoginView
from .models import Document, MachineEvent, WorkShift, WorkPeriod
from django.apps import apps
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
from docx import Document as DocxDocument
from io import BytesIO
GREEN = "rgb(182, 237, 227)"
RED = "rgb(248, 192, 185)"
GRAY = "rgb(224, 226, 229)"
class CustomLoginView(LoginView):
template_name = 'auth/login.html'
redirect_authenticated_user = True
def time_format(timestamp):
hours, remainder = divmod(timestamp.seconds, 3600)
minutes, sec = divmod(remainder, 60)
t = f"{hours} ч. {minutes} м. {sec} с."
return t
@login_required
def get_status(request):
today = timezone.now().date()
workships = WorkShift.objects.filter(date=today)
if workships.count()<=0:
run_time = 'Смена не задана'
sleep_time = 'Смена не задана'
else:
workship_last = workships[0]
run_time = time_format(workship_last.total_working_time)
sleep_time = time_format(workship_last.total_down_time)
last_events = MachineEvent.objects.latest('id')
status = int(last_events.status)
value = ["Простаивает", "Работает"][status]
color = ["#FBE0DD", "#DCF6F1"][status]
return JsonResponse({'value': value, 'color': color, 'run_time': run_time, 'sleep_time': sleep_time})
@login_required
def get_chart_data(request):
data = {
"labels": ["Активность"],
"datasets": []
}
# тут получаются данные для графика периодов простоя
start_of_day = timezone.now().replace(hour=0, minute=0, second=0, microsecond=0)
end_of_day = start_of_day + timezone.timedelta(days=1)
periods = WorkPeriod.objects.filter(start_time__gte=start_of_day, end_time__lt=end_of_day)
for i in periods:
tooltip_text = f"Начало: {i.start_time.strftime('%H:%M:%S')}, Конец: {i.end_time.strftime('%H:%M:%S')}"
data_template = {
'label': 'время',
'data': [int((i.end_time - i.start_time).total_seconds())],
'id': i.id,
'borderRadius': 8,
'tooltip': tooltip_text
}
if i.status:
data_template['backgroundColor'] = GREEN
elif i.reason is not None:
data_template['backgroundColor'] = GRAY
else:
data_template['backgroundColor'] = RED
data_template['data'] = [int((i.end_time-i.start_time).total_seconds())]
data['datasets'].append(data_template)
return JsonResponse(data)
@login_required
def stats_page(request):
# страница с видеопотоком и блоком информации
context = {"status": "Простаивает"}
return render(request, "client_app/stats.html", context)
@login_required
def report_page(request):
# страница с отчетами
documents = Document.objects.all().order_by('-id')
return render(request, "client_app/report.html", {'documents': documents})
@login_required
def create_report(request):
if request.method == 'POST':
title = request.POST.get('title')
period = request.POST.get('period')
Document.objects.create(title=title, period=period)
return redirect('/report/')
return render(request, 'client_app/create_report.html')
@login_required
def download_report(request, document_id):
document = get_object_or_404(Document, id=document_id)
doc = DocxDocument()
doc.add_heading(document.title, level=1)
doc.add_paragraph(f"Дата создания: {document.created_at}")
doc.add_paragraph(f"Период: {document.period}")
file_stream = BytesIO()
doc.save(file_stream)
file_stream.seek(0)
response = HttpResponse(file_stream, content_type='application/vnd.openxmlformats-officedocument.wordprocessingml.document')
response['Content-Disposition'] = f'attachment; filename="{document.title}.docx"'
return response
@login_required
def reason_page(request):
# страница с графиком периодов простоя
return render(request, "client_app/reason.html")
@login_required
def admin_client(request):
data = []
model_name_list = ["Machine", "Worker", "WorkShift", "Document"]
for model_name in model_name_list:
model = apps.get_model('client_app', model_name)
objects = model.objects.all()
model_values = []
for obj in objects:
values = [getattr(obj, field.name) for field in model._meta.fields]
model_values.append(values)
model_data = {'name': model._meta.verbose_name_plural,
'fields': [field.verbose_name for field in model._meta.fields],
'model_values': model_values,
}
data.append(model_data)
return render(request, 'client_app/admin_client.html', {
'data': data
})
def dynamic_table(request, model_name):
model = apps.get_model('client_app', model_name)
fields = [field.verbose_name for field in model._meta.fields]
objects = model.objects.all()
result = []
for obj in objects:
values = [getattr(obj, field.name) for field in model._meta.fields]
result.append(values)
return render(request, 'client_app/admin_table.html', {
'model_name': model_name,
'fields': fields,
'objects': result,
'add': model_name.lower()
})
def dynamic_detail(request, model_name, object_id):
model = apps.get_model('client_app', model_name)
obj = get_object_or_404(model, id=object_id)
return render(request, 'dynamic_detail.html', {
'model_name': model_name,
'object': obj
})

View File

@ -1,51 +0,0 @@
.container_table {
width: 600px;
border: 1px solid #ccc;
border-radius: 8px;
margin: 10px;
padding: 10px;
background: white;
}
.header_table {
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
padding: 10px;
background: #f0f0f0;
border-radius: 8px;
}
.content_table {
max-height: 200px;
overflow-y: auto;
display: none;
margin-top: 10px;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 8px;
border-bottom: 1px solid #ddd;
}
tr:hover {
background-color: #f1f1f1;
cursor: pointer;
}
.icon {
font-size: 20px;
transition: transform 0.3s;
margin-left: 10px;
}
.expanded .icon {
transform: rotate(180deg);
}

View File

@ -1,82 +0,0 @@
body {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
background-color: #F4F5F6;
}
.main-header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #DAE6FF;
color: #0A5BFF;
padding: 15px 30px;
border-radius: 15px;
margin: 20px;
text-align: center;
/* max-width: 1300px; */
}
.content {
max-height: 10000px;
overflow-y: auto;
}
.top-nav a {
color: white;
text-decoration: none;
margin-left: 15px;
}
.wrapper {
width: 100%;
height: 100%;
display: flex;
flex-grow: 1;
/* margin-top: 20px; */
gap: 20px;
}
.sidebar {
height: 100%;
width: 250px;
background-color: #FFFFFF;
padding-top: 20px;
transition: width 0.3s ease;
overflow: hidden;
border-radius: 15px;
margin-left: 20px;
}
.sidebar a {
display: block;
color: #8A8894;
padding: 10px;
text-decoration: none;
white-space: nowrap;
}
.sidebar a:hover {
background-color: #DAE6FF;
}
.sidebar.collapsed {
width: 60px;
}
.sidebar.collapsed a {
text-align: 60px;
}
.toggle-btn{
background-color: #DAE6FF;
border-radius: 6px;
}
.logout-button{
background-color: #DAE6FF;
border: none;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,93 +0,0 @@
/* ckeditor.css */
.ck-editor__editable {
min-height: 300px;
border: 1px solid #e0e0e0;
border-radius: 4px;
padding: 15px;
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.ck-toolbar {
border: 1px solid #e0e0e0;
border-radius: 4px 4px 0 0;
background-color: #f5f5f5;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.ck-button {
color: #333;
border-radius: 4px;
transition: background-color 0.2s;
}
.ck-button:hover {
background-color: #e0e0e0;
}
.ck-dropdown__panel {
border: 1px solid #e0e0e0;
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.ck-dropdown__panel .ck-button {
padding: 8px 12px;
}
.ck-dropdown__panel .ck-button:hover {
background-color: #f0f0f0;
}
.ck-content h1, .ck-content h2, .ck-content h3 {
color: #333;
font-weight: bold;
}
.ck-content p {
color: #555;
line-height: 1.6;
}
.ck-content a {
color: #007bff;
text-decoration: none;
}
.ck-content a:hover {
text-decoration: underline;
}
/* ckeditor.css */
.ck-content code {
background-color: #f5f5f5;
padding: 2px 4px;
border-radius: 3px;
font-family: "Courier New", monospace;
}
.ck-content table {
width: 100%;
border-collapse: collapse;
margin: 10px 0;
background-color: #333;
}
.ck-content table td, .ck-content table th {
border: 1px solid #ddd;
padding: 8px;
}
.ck-content table th {
background-color: #f5f5f5;
font-weight: bold;
}
.ck-content .todo-list li {
list-style-type: none;
margin-left: 0;
}
.ck-content .todo-list li input[type="checkbox"] {
margin-right: 8px;
}

View File

@ -1,71 +0,0 @@
body {
display: flex;
flex-direction: column;
margin: 0;
margin-top: 100px;
margin-left: 100px;
}
.main-header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #DAE6FF;
color: #0A5BFF;
padding: 15px 30px;
border-radius: 15px;
margin-top: 20px;
margin-left: 20px;
text-align: center;
max-width: 1300px;
}
.top-nav a {
color: white;
text-decoration: none;
margin-left: 15px;
}
.wrapper {
display: flex;
flex-grow: 1;
margin-top: 20px;
gap: 20px;
}
.sidebar {
height: 100vh;
width: 250px;
background-color: #FFFFFF;
padding-top: 20px;
transition: width 0.3s ease;
overflow: hidden;
border-radius: 15px;
margin-left: 20px;
}
.sidebar a {
display: block;
color: #8A8894;
padding: 10px;
text-decoration: none;
white-space: nowrap;
}
.sidebar a:hover {
background-color: #DAE6FF;
}
.sidebar.collapsed {
width: 60px;
}
.sidebar.collapsed a {
text-align: 60px;
}
.toggle-btn{
background-color: #DAE6FF;
border-radius: 6px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

View File

@ -1,80 +0,0 @@
body {
background-color: #F4F5F6;
margin: 0;
padding: 0;
}
.title-box {
background: #DAE6FF;
/* padding: 15px 30px; */
border-radius: 10px;
color: #0A5BFF;
font-size: 48px;
font-weight: bold;
text-align: center;
max-width: 1000px;
width: 100%;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.main-container {
background-color: #F4F5F6;
display: flex;
/* flex-direction: column; */
gap: 20px;
width: 100%;
}
.left-panel {
flex: 2;
background: #FFFFFF;
border-radius: 10px;
padding: 20px;
height: 500px;
max-width: 700px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.right-panel {
flex: 1;
display: flex;
flex-direction: column;
gap: 20px;
max-width: 300px;
}
.small-box {
background: #FFFFFF;
border-radius: 10px;
padding: 20px;
height: 200px;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.button-box {
background: #0A5BFF;
color: white;
text-align: center;
border-radius: 10px;
padding: 15px;
cursor: pointer;
}
.button-box:hover{
background: #0952E6;
}
.label-container {
display: flex;
align-items: center;
gap: 10px;
}
.label-box {
background: #C5CCD4;
padding: 5px;
border-radius: 5px;
}
.report-box {
background: white;
display: flex;
border-radius: 10px;
}

View File

@ -1,129 +0,0 @@
:root {
--primary: #6366f1;
--primary-hover: #4f46e5;
--background: #f8fafc;
--text: #0f172a;
--gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', system-ui, sans-serif;
}
body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: var(--background);
padding: 1rem;
line-height: 1.5;
color: var(--text);
}
.error-container {
text-align: center;
max-width: 600px;
padding: 2rem;
background: white;
border-radius: 1.5rem;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
position: relative;
overflow: hidden;
}
.error-container::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 8px;
background: var(--gradient);
}
.error-graphic {
width: 200px;
height: 200px;
margin: 0 auto 2rem;
position: relative;
animation: float 3s ease-in-out infinite;
}
.error-code {
font-size: 4rem;
font-weight: 800;
background: var(--gradient);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
margin-bottom: 0.5rem;
}
h1 {
font-size: 1.875rem;
margin-bottom: 1rem;
color: var(--text);
}
.error-message {
color: #64748b;
margin-bottom: 2rem;
}
.actions {
display: flex;
gap: 1rem;
justify-content: center;
}
.btn {
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
font-weight: 500;
transition: all 0.2s;
text-decoration: none;
display: inline-flex;
align-items: center;
gap: 0.5rem;
}
.btn-primary {
background: var(--primary);
color: white;
border: 2px solid var(--primary);
}
.btn-primary:hover {
background: var(--primary-hover);
transform: translateY(-2px);
}
.btn-secondary {
border: 2px solid #e2e8f0;
color: var(--text);
background: white;
}
.btn-secondary:hover {
border-color: #cbd5e1;
background: #f8fafc;
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-20px); }
}
@media (max-width: 640px) {
.error-code {
font-size: 3rem;
}
h1 {
font-size: 1.5rem;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 4.4 MiB

View File

@ -1,21 +0,0 @@
{
"name": "MyWebSite",
"short_name": "MySite",
"icons": [
{
"src": "/static/favicon/web-app-manifest-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/static/favicon/web-app-manifest-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 KiB

View File

@ -1,104 +0,0 @@
document.addEventListener('DOMContentLoaded', function () {
"use strict"; // Строгий режим
console.log("DOM загружен"); // Отладочное сообщение
// Инициализация Scrollspy
let scrollSpy = new bootstrap.ScrollSpy(document.body, {
target: '#page-nav',
smoothScroll: true
});
// Кнопка для мобильной навигации
const toggleNavButton = document.getElementById('toggle-nav');
const leftNav = document.getElementById('left-nav');
const rightNav = document.getElementById('right-nav');
console.log("toggleNavButton:", toggleNavButton); // Отладочное сообщение
console.log("leftNav:", leftNav); // Отладочное сообщение
console.log("rightNav:", rightNav); // Отладочное сообщение
if (toggleNavButton && leftNav && rightNav) {
toggleNavButton.addEventListener('click', function () {
console.log("Кнопка нажата"); // Отладочное сообщение
if (leftNav.classList.contains('d-none')) {
leftNav.classList.remove('d-none');
rightNav.classList.remove('d-none');
this.textContent = 'Скрыть навигацию';
} else {
leftNav.classList.add('d-none');
rightNav.classList.add('d-none');
this.textContent = 'Показать навигацию';
}
});
} else {
console.error("Один из элементов не найден"); // Отладочное сообщение
}
// Поиск по странице
const searchForm = document.getElementById('search-form');
const searchInput = document.getElementById('search-input');
if (searchForm && searchInput) {
searchForm.addEventListener('submit', function (event) {
event.preventDefault(); // Отменяем стандартное поведение формы
const searchQuery = searchInput.value.trim();
if (searchQuery === '') {
alert('Введите текст для поиска.');
return;
}
// Очищаем предыдущие выделения
clearHighlights();
// Ищем и выделяем текст
const pageContents = document.querySelectorAll('.page-content');
let found = false;
let firstHighlight = null; // Первое найденное выделение
pageContents.forEach(page => {
const contentElements = page.querySelectorAll('.content p'); // Ищем текст внутри <p>
contentElements.forEach(element => {
const text = element.textContent;
const regex = new RegExp(`(${searchQuery})`, 'gi'); // Регулярное выражение для поиска
const newText = text.replace(regex, '<span class="highlight">$1</span>'); // Заменяем найденное слово на выделенный текст
if (newText !== text) {
element.innerHTML = newText; // Обновляем содержимое элемента
found = true;
// Если это первое найденное выделение, сохраняем его
if (!firstHighlight) {
firstHighlight = element.querySelector('.highlight');
}
}
});
});
// Прокрутка к первому найденному выделению
if (firstHighlight) {
firstHighlight.scrollIntoView({
behavior: 'smooth', // Плавная прокрутка
block: 'center' // Прокрутка к центру экрана
});
}
if (!found) {
alert('Ничего не найдено.');
}
});
// Функция для очистки выделений
function clearHighlights() {
const highlights = document.querySelectorAll('.highlight');
highlights.forEach(highlight => {
const text = highlight.textContent;
highlight.replaceWith(text); // Убираем выделение
});
}
} else {
console.error("Форма поиска или поле ввода не найдены"); // Отладочное сообщение
}
});

File diff suppressed because one or more lines are too long

View File

@ -1,60 +0,0 @@
/* Стили для модального окна */
#modal {
border: none;
border-radius: 10px;
padding: 20px;
width: 300px;
}
/* Заголовок модального окна */
.modal-header {
font-size: 18px;
font-weight: bold;
margin-bottom: 10px;
}
/* Метка */
.modal-label {
display: block;
font-size: 14px;
opacity: 0.6;
margin-bottom: 5px;
}
/* Поле ввода */
.modal-textarea {
width: 100%;
height: 80px;
border-radius: 8px;
border: 1px solid #ccc;
padding: 8px;
resize: none;
}
/* Подвал модального окна */
.modal-footer {
display: flex;
justify-content: space-between;
margin-top: 15px;
}
/* Общие стили для кнопок */
.modal-button {
border: none;
font-size: 14px;
cursor: pointer;
border-radius: 6px;
padding: 8px 12px;
}
/* Кнопка "Закрыть" */
.modal-button.close {
background: transparent;
color: #007bff;
}
/* Кнопка "Отправить" */
.modal-button.submit {
background-color: #007bff;
color: white;
}

View File

@ -1,46 +0,0 @@
.documents-container {
display: flex;
flex-wrap: wrap;
gap: 20px;
}
.document-box {
border: 1px solid #ddd;
padding: 20px;
width: 200px;
background-color: #f9f9f9;
text-align: center;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.document-icon {
font-size: 40px;
color: #555;
margin-bottom: 10px;
}
.document-info {
font-size: 14px;
margin-bottom: 10px;
}
.download-link {
display: inline-block;
padding: 8px 15px;
background-color: #0A5BFF;
color: white;
text-decoration: none;
border-radius: 5px;
font-size: 14px;
}
.download-link:hover {
background-color: #0341be;
}
.no-documents {
text-align: center;
font-size: 16px;
color: #777;
}

View File

View File

@ -1,247 +0,0 @@
<#
.Synopsis
Activate a Python virtual environment for the current PowerShell session.
.Description
Pushes the python executable for a virtual environment to the front of the
$Env:PATH environment variable and sets the prompt to signify that you are
in a Python virtual environment. Makes use of the command line switches as
well as the `pyvenv.cfg` file values present in the virtual environment.
.Parameter VenvDir
Path to the directory that contains the virtual environment to activate. The
default value for this is the parent of the directory that the Activate.ps1
script is located within.
.Parameter Prompt
The prompt prefix to display when this virtual environment is activated. By
default, this prompt is the name of the virtual environment folder (VenvDir)
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
.Example
Activate.ps1
Activates the Python virtual environment that contains the Activate.ps1 script.
.Example
Activate.ps1 -Verbose
Activates the Python virtual environment that contains the Activate.ps1 script,
and shows extra information about the activation as it executes.
.Example
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
Activates the Python virtual environment located in the specified location.
.Example
Activate.ps1 -Prompt "MyPython"
Activates the Python virtual environment that contains the Activate.ps1 script,
and prefixes the current prompt with the specified string (surrounded in
parentheses) while the virtual environment is active.
.Notes
On Windows, it may be required to enable this Activate.ps1 script by setting the
execution policy for the user. You can do this by issuing the following PowerShell
command:
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
For more information on Execution Policies:
https://go.microsoft.com/fwlink/?LinkID=135170
#>
Param(
[Parameter(Mandatory = $false)]
[String]
$VenvDir,
[Parameter(Mandatory = $false)]
[String]
$Prompt
)
<# Function declarations --------------------------------------------------- #>
<#
.Synopsis
Remove all shell session elements added by the Activate script, including the
addition of the virtual environment's Python executable from the beginning of
the PATH variable.
.Parameter NonDestructive
If present, do not remove this function from the global namespace for the
session.
#>
function global:deactivate ([switch]$NonDestructive) {
# Revert to original values
# The prior prompt:
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
}
# The prior PYTHONHOME:
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
}
# The prior PATH:
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
}
# Just remove the VIRTUAL_ENV altogether:
if (Test-Path -Path Env:VIRTUAL_ENV) {
Remove-Item -Path env:VIRTUAL_ENV
}
# Just remove VIRTUAL_ENV_PROMPT altogether.
if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
Remove-Item -Path env:VIRTUAL_ENV_PROMPT
}
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
}
# Leave deactivate function in the global namespace if requested:
if (-not $NonDestructive) {
Remove-Item -Path function:deactivate
}
}
<#
.Description
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
given folder, and returns them in a map.
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
two strings separated by `=` (with any amount of whitespace surrounding the =)
then it is considered a `key = value` line. The left hand string is the key,
the right hand is the value.
If the value starts with a `'` or a `"` then the first and last character is
stripped from the value before being captured.
.Parameter ConfigDir
Path to the directory that contains the `pyvenv.cfg` file.
#>
function Get-PyVenvConfig(
[String]
$ConfigDir
) {
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
# An empty map will be returned if no config file is found.
$pyvenvConfig = @{ }
if ($pyvenvConfigPath) {
Write-Verbose "File exists, parse `key = value` lines"
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
$pyvenvConfigContent | ForEach-Object {
$keyval = $PSItem -split "\s*=\s*", 2
if ($keyval[0] -and $keyval[1]) {
$val = $keyval[1]
# Remove extraneous quotations around a string value.
if ("'""".Contains($val.Substring(0, 1))) {
$val = $val.Substring(1, $val.Length - 2)
}
$pyvenvConfig[$keyval[0]] = $val
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
}
}
}
return $pyvenvConfig
}
<# Begin Activate script --------------------------------------------------- #>
# Determine the containing directory of this script
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
$VenvExecDir = Get-Item -Path $VenvExecPath
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
# Set values required in priority: CmdLine, ConfigFile, Default
# First, get the location of the virtual environment, it might not be
# VenvExecDir if specified on the command line.
if ($VenvDir) {
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
}
else {
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
Write-Verbose "VenvDir=$VenvDir"
}
# Next, read the `pyvenv.cfg` file to determine any required value such
# as `prompt`.
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
# Next, set the prompt from the command line, or the config file, or
# just use the name of the virtual environment folder.
if ($Prompt) {
Write-Verbose "Prompt specified as argument, using '$Prompt'"
}
else {
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
$Prompt = $pyvenvCfg['prompt'];
}
else {
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
$Prompt = Split-Path -Path $venvDir -Leaf
}
}
Write-Verbose "Prompt = '$Prompt'"
Write-Verbose "VenvDir='$VenvDir'"
# Deactivate any currently active virtual environment, but leave the
# deactivate function in place.
deactivate -nondestructive
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
# that there is an activated venv.
$env:VIRTUAL_ENV = $VenvDir
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
Write-Verbose "Setting prompt to '$Prompt'"
# Set the prompt to include the env name
# Make sure _OLD_VIRTUAL_PROMPT is global
function global:_OLD_VIRTUAL_PROMPT { "" }
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
function global:prompt {
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
_OLD_VIRTUAL_PROMPT
}
$env:VIRTUAL_ENV_PROMPT = $Prompt
}
# Clear PYTHONHOME
if (Test-Path -Path Env:PYTHONHOME) {
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
Remove-Item -Path Env:PYTHONHOME
}
# Add the venv to the PATH
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"

View File

@ -1,70 +0,0 @@
# This file must be used with "source bin/activate" *from bash*
# You cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# Call hash to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
hash -r 2> /dev/null
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
unset VIRTUAL_ENV_PROMPT
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
# on Windows, a path can contain colons and backslashes and has to be converted:
if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
# transform D:\path\to\venv to /d/path/to/venv on MSYS
# and to /cygdrive/d/path/to/venv on Cygwin
export VIRTUAL_ENV=$(cygpath /home/efim/project/zircon/tools/labelme)
else
# use the path as-is
export VIRTUAL_ENV=/home/efim/project/zircon/tools/labelme
fi
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/"bin":$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "${PYTHONHOME:-}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1='(labelme) '"${PS1:-}"
export PS1
VIRTUAL_ENV_PROMPT='(labelme) '
export VIRTUAL_ENV_PROMPT
fi
# Call hash to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
hash -r 2> /dev/null

View File

@ -1,27 +0,0 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
# Unset irrelevant variables.
deactivate nondestructive
setenv VIRTUAL_ENV /home/efim/project/zircon/tools/labelme
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/"bin":$PATH"
set _OLD_VIRTUAL_PROMPT="$prompt"
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
set prompt = '(labelme) '"$prompt"
setenv VIRTUAL_ENV_PROMPT '(labelme) '
endif
alias pydoc python -m pydoc
rehash

View File

@ -1,69 +0,0 @@
# This file must be used with "source <venv>/bin/activate.fish" *from fish*
# (https://fishshell.com/). You cannot run it directly.
function deactivate -d "Exit virtual environment and return to normal shell environment"
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
set -e _OLD_FISH_PROMPT_OVERRIDE
# prevents error when using nested fish instances (Issue #93858)
if functions -q _old_fish_prompt
functions -e fish_prompt
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
end
end
set -e VIRTUAL_ENV
set -e VIRTUAL_ENV_PROMPT
if test "$argv[1]" != "nondestructive"
# Self-destruct!
functions -e deactivate
end
end
# Unset irrelevant variables.
deactivate nondestructive
set -gx VIRTUAL_ENV /home/efim/project/zircon/tools/labelme
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/"bin $PATH
# Unset PYTHONHOME if set.
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish uses a function instead of an env var to generate the prompt.
# Save the current fish_prompt function as the function _old_fish_prompt.
functions -c fish_prompt _old_fish_prompt
# With the original prompt function renamed, we can override with our own.
function fish_prompt
# Save the return status of the last command.
set -l old_status $status
# Output the venv prompt; color taken from the blue of the Python logo.
printf "%s%s%s" (set_color 4B8BBE) '(labelme) ' (set_color normal)
# Restore the return status of the previous command.
echo "exit $old_status" | .
# Output the original/"old" prompt.
_old_fish_prompt
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
set -gx VIRTUAL_ENV_PROMPT '(labelme) '
end

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from coloredlogs.cli import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from numpy.f2py.f2py2e import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from fontTools.__main__ import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from gdown.__main__ import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from humanfriendly.cli import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from imageio.__main__ import download_bin_main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(download_bin_main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from imageio.__main__ import remove_bin_main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(remove_bin_main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from isympy import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from labelme.__main__ import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from labelme.cli.draw_json import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from labelme.cli.draw_label_png import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from labelme.cli.export_json import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from labelme.cli.json_to_dataset import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from labelme.cli.on_docker import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from tifffile.lsm2bin import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from natsort.__main__ import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from charset_normalizer import cli
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(cli.cli_detect())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from numpy._configtool import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from onnxruntime.tools.onnxruntime_test import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from osam import __main__
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(__main__.cli())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from fontTools.merge import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from fontTools.subset import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -1,8 +0,0 @@
#!/home/efim/project/zircon/tools/labelme/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from PyQt5.pylupdate_main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

Some files were not shown because too many files have changed in this diff Show More