调整目录结构

This commit is contained in:
2025-10-23 18:57:37 +08:00
parent 6cf4d9cb03
commit 4966a659aa
2173 changed files with 4343 additions and 11 deletions

View File

@@ -0,0 +1,502 @@
<#
.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"
# SIG # Begin signature block
# MIIvJAYJKoZIhvcNAQcCoIIvFTCCLxECAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBnL745ElCYk8vk
# dBtMuQhLe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/gsorVMEA
# rx/apEwf1F70vD2caiIsUAhrmPzyslFZfU6o2fKXI/vrBTUvbzb5Vz+IGoXlwTH+
# loWh4loof+pJjbpJJj26GQwssAl3M/m/3BGamnmf97CJShvPrM0w8WOLkXtn6/M4
# Y15ywECiRhaQX7NUVzRBl1hGDDD0mFv/OHzMer3C4/8I04whBnfvMxelUb4YhlM6
# e+F6DzvI91OWTrpjsPKOHE3ds9ra+F1yPkV1RMQMRx/xWd0D274R8W2baHxrYgS3
# 2LYPSAYFMi3cmF6Df84iIG2d0qj0x3ioXDUUk72YTCUO1Xnz9jkHSCU7Bq2GL9uP
# z4sEyNDU23dEmfGD672vMRuZ6Ua/ks5J
# SIG # End signature block

View File

@@ -0,0 +1,76 @@
# 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
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi
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 "E:\code\Python\iOSAi\build\mini-python")
else
# use the path as-is
export VIRTUAL_ENV="E:\code\Python\iOSAi\build\mini-python"
fi
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/Scripts:$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="(mini-python) ${PS1:-}"
export PS1
VIRTUAL_ENV_PROMPT="(mini-python) "
export VIRTUAL_ENV_PROMPT
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi

View File

@@ -0,0 +1,34 @@
@echo off
rem This file is UTF-8 encoded, so we need to update the current code page while executing it
for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do (
set _OLD_CODEPAGE=%%a
)
if defined _OLD_CODEPAGE (
"%SystemRoot%\System32\chcp.com" 65001 > nul
)
set VIRTUAL_ENV=E:\code\Python\iOSAi\build\mini-python
if not defined PROMPT set PROMPT=$P$G
if defined _OLD_VIRTUAL_PROMPT set PROMPT=%_OLD_VIRTUAL_PROMPT%
if defined _OLD_VIRTUAL_PYTHONHOME set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%
set _OLD_VIRTUAL_PROMPT=%PROMPT%
set PROMPT=(mini-python) %PROMPT%
if defined PYTHONHOME set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%
set PYTHONHOME=
if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%
if not defined _OLD_VIRTUAL_PATH set _OLD_VIRTUAL_PATH=%PATH%
set PATH=%VIRTUAL_ENV%\Scripts;%PATH%
set VIRTUAL_ENV_PROMPT=(mini-python)
:END
if defined _OLD_CODEPAGE (
"%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
set _OLD_CODEPAGE=
)

Binary file not shown.

View File

@@ -0,0 +1,22 @@
@echo off
if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
)
set _OLD_VIRTUAL_PROMPT=
if defined _OLD_VIRTUAL_PYTHONHOME (
set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
set _OLD_VIRTUAL_PYTHONHOME=
)
if defined _OLD_VIRTUAL_PATH (
set "PATH=%_OLD_VIRTUAL_PATH%"
)
set _OLD_VIRTUAL_PATH=
set VIRTUAL_ENV=
set VIRTUAL_ENV_PROMPT=
:END

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,149 @@
#!C:\Users\milk\AppData\Local\Programs\Python\Python312\python.exe
"""
Command line utility to extract basic statistics from gpx file(s)
"""
import pdb
import sys as mod_sys
import logging as mod_logging
import math as mod_math
import argparse as mod_argparse
import gpxpy as mod_gpxpy
import gpxpy.gpx as mod_gpx
from typing import *
KM_TO_MILES = 0.621371
M_TO_FEET = 3.28084
def format_time(time_s: float) -> str:
if not time_s:
return 'n/a'
elif args.seconds:
return str(int(time_s))
else:
minutes = mod_math.floor(time_s / 60.)
hours = mod_math.floor(minutes / 60.)
return '%s:%s:%s' % (str(int(hours)).zfill(2), str(int(minutes % 60)).zfill(2), str(int(time_s % 60)).zfill(2))
def format_long_length(length: float) -> str:
if args.miles:
return '{:.3f}miles'.format(length / 1000. * KM_TO_MILES)
else:
return '{:.3f}km'.format(length / 1000.)
def format_short_length(length: float) -> str:
if args.miles:
return '{:.2f}ft'.format(length * M_TO_FEET)
else:
return '{:.2f}m'.format(length)
def format_speed(speed: float) -> str:
if not speed:
speed = 0
if args.miles:
return '{:.2f}mph'.format(speed * KM_TO_MILES * 3600. / 1000.)
else:
return '{:.2f}m/s = {:.2f}km/h'.format(speed, speed * 3600. / 1000.)
def print_gpx_part_info(gpx_part: Union[mod_gpx.GPX, mod_gpx.GPXTrack, mod_gpx.GPXTrackSegment], indentation: str=' ') -> None:
"""
gpx_part may be a track or segment.
"""
length_2d = gpx_part.length_2d()
length_3d = gpx_part.length_3d()
print('%sLength 2D: %s' % (indentation, format_long_length(length_2d or 0)))
print('%sLength 3D: %s' % (indentation, format_long_length(length_3d)))
moving_data = gpx_part.get_moving_data()
raw_moving_data = gpx_part.get_moving_data(raw=True)
if moving_data:
print(f'{indentation}Moving time: {format_time(moving_data.moving_time)}')
print(f'{indentation}Stopped time: {format_time(moving_data.stopped_time)}')
print(f'{indentation}Max speed: {format_speed(moving_data.max_speed)} (raw: {format_speed(raw_moving_data.max_speed) if raw_moving_data else "?"})')
print(f'{indentation}Avg speed: {format_speed(moving_data.moving_distance / moving_data.moving_time) if moving_data.moving_time > 0 else "?"}')
uphill, downhill = gpx_part.get_uphill_downhill()
print('%sTotal uphill: %s' % (indentation, format_short_length(uphill)))
print('%sTotal downhill: %s' % (indentation, format_short_length(downhill)))
start_time, end_time = gpx_part.get_time_bounds()
print('%sStarted: %s' % (indentation, start_time))
print('%sEnded: %s' % (indentation, end_time))
points_no = len(list(gpx_part.walk(only_points=True)))
print('%sPoints: %s' % (indentation, points_no))
if points_no > 0:
distances: List[float] = []
previous_point = None
for point in gpx_part.walk(only_points=True):
if previous_point:
distance = point.distance_2d(previous_point)
distances.append(distance)
previous_point = point
print('%sAvg distance between points: %s' % (indentation, format_short_length(sum(distances) / len(list(gpx_part.walk())))))
print('')
def print_gpx_info(gpx: mod_gpx.GPX, gpx_file: str) -> None:
print('File: %s' % gpx_file)
if gpx.name:
print(' GPX name: %s' % gpx.name)
if gpx.description:
print(' GPX description: %s' % gpx.description)
if gpx.author_name:
print(' Author: %s' % gpx.author_name)
if gpx.author_email:
print(' Email: %s' % gpx.author_email)
print_gpx_part_info(gpx)
for track_no, track in enumerate(gpx.tracks):
for segment_no, segment in enumerate(track.segments):
print(' Track #%s, Segment #%s' % (track_no, segment_no))
print_gpx_part_info(segment, indentation=' ')
def run(gpx_files: List[str]) -> None:
if not gpx_files:
print('No GPX files given')
mod_sys.exit(1)
for gpx_file in gpx_files:
try:
gpx = mod_gpxpy.parse(open(gpx_file))
print_gpx_info(gpx, gpx_file)
except Exception as e:
mod_logging.exception(e)
print('Error processing %s' % gpx_file)
mod_sys.exit(1)
def make_parser() -> mod_argparse.ArgumentParser:
parser = mod_argparse.ArgumentParser(usage='%(prog)s [-s] [-m] [-d] [file ...]',
description='Command line utility to extract basic statistics from gpx file(s)')
parser.add_argument('-s', '--seconds', action='store_true',
help='print times as N seconds, rather than HH:MM:SS')
parser.add_argument('-m', '--miles', action='store_true',
help='print distances and speeds using miles and feet')
parser.add_argument('-d', '--debug', action='store_true',
help='show detailed logging')
return parser
if __name__ == '__main__':
args, gpx_files = make_parser().parse_known_args()
if args.debug:
mod_logging.basicConfig(level=mod_logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
run(gpx_files)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,24 @@
@echo off
rem Copyright 2025, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
setlocal
"%~dp0nuitka.cmd --run %*"
endlocal
rem Part of "Nuitka", an optimizing Python compiler that is compatible and
rem integrates with CPython, but also works on its own.
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

View File

@@ -0,0 +1,30 @@
@echo off
rem Copyright 2025, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
setlocal
if exist "%~dp0..\python.exe" (
"%~dp0..\python" -m nuitka %*
) else if exist "%~dp0python.exe" (
"%~dp0python" -m nuitka %*
) else (
"python" -m nuitka %*
)
endlocal
rem Part of "Nuitka", an optimizing Python compiler that is compatible and
rem integrates with CPython, but also works on its own.
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,733 @@
# postinstall script for pywin32
#
# copies pywintypesXX.dll and pythoncomXX.dll into the system directory,
# and creates a pth file
import argparse
import glob
import os
import shutil
import sys
import sysconfig
import tempfile
import winreg
tee_f = open(
os.path.join(
tempfile.gettempdir(), # Send output somewhere so it can be found if necessary...
"pywin32_postinstall.log",
),
"w",
)
class Tee:
def __init__(self, file):
self.f = file
def write(self, what):
if self.f is not None:
try:
self.f.write(what.replace("\n", "\r\n"))
except OSError:
pass
tee_f.write(what)
def flush(self):
if self.f is not None:
try:
self.f.flush()
except OSError:
pass
tee_f.flush()
sys.stderr = Tee(sys.stderr)
sys.stdout = Tee(sys.stdout)
com_modules = [
# module_name, class_names
("win32com.servers.interp", "Interpreter"),
("win32com.servers.dictionary", "DictionaryPolicy"),
("win32com.axscript.client.pyscript", "PyScript"),
]
# Is this a 'silent' install - ie, avoid all dialogs.
# Different than 'verbose'
silent = 0
# Verbosity of output messages.
verbose = 1
root_key_name = "Software\\Python\\PythonCore\\" + sys.winver
def get_root_hkey():
try:
winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE, root_key_name, 0, winreg.KEY_CREATE_SUB_KEY
)
return winreg.HKEY_LOCAL_MACHINE
except OSError:
# Either not exist, or no permissions to create subkey means
# must be HKCU
return winreg.HKEY_CURRENT_USER
# Create a function with the same signature as create_shortcut
# previously provided by bdist_wininst
def create_shortcut(
path, description, filename, arguments="", workdir="", iconpath="", iconindex=0
):
import pythoncom
from win32com.shell import shell
ilink = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink,
)
ilink.SetPath(path)
ilink.SetDescription(description)
if arguments:
ilink.SetArguments(arguments)
if workdir:
ilink.SetWorkingDirectory(workdir)
if iconpath or iconindex:
ilink.SetIconLocation(iconpath, iconindex)
# now save it.
ipf = ilink.QueryInterface(pythoncom.IID_IPersistFile)
ipf.Save(filename, 0)
# Support the same list of "path names" as bdist_wininst used to
def get_special_folder_path(path_name):
from win32com.shell import shell, shellcon
for maybe in """
CSIDL_COMMON_STARTMENU CSIDL_STARTMENU CSIDL_COMMON_APPDATA
CSIDL_LOCAL_APPDATA CSIDL_APPDATA CSIDL_COMMON_DESKTOPDIRECTORY
CSIDL_DESKTOPDIRECTORY CSIDL_COMMON_STARTUP CSIDL_STARTUP
CSIDL_COMMON_PROGRAMS CSIDL_PROGRAMS CSIDL_PROGRAM_FILES_COMMON
CSIDL_PROGRAM_FILES CSIDL_FONTS""".split():
if maybe == path_name:
csidl = getattr(shellcon, maybe)
return shell.SHGetSpecialFolderPath(0, csidl, False)
raise ValueError(f"{path_name} is an unknown path ID")
def CopyTo(desc, src, dest):
import win32api
import win32con
while 1:
try:
win32api.CopyFile(src, dest, 0)
return
except win32api.error as details:
if details.winerror == 5: # access denied - user not admin.
raise
if silent:
# Running silent mode - just re-raise the error.
raise
full_desc = (
f"Error {desc}\n\n"
"If you have any Python applications running, "
f"please close them now\nand select 'Retry'\n\n{details.strerror}"
)
rc = win32api.MessageBox(
0, full_desc, "Installation Error", win32con.MB_ABORTRETRYIGNORE
)
if rc == win32con.IDABORT:
raise
elif rc == win32con.IDIGNORE:
return
# else retry - around we go again.
# We need to import win32api to determine the Windows system directory,
# so we can copy our system files there - but importing win32api will
# load the pywintypes.dll already in the system directory preventing us
# from updating them!
# So, we pull the same trick pywintypes.py does, but it loads from
# our pywintypes_system32 directory.
def LoadSystemModule(lib_dir, modname):
# See if this is a debug build.
import importlib.machinery
import importlib.util
suffix = "_d" if "_d.pyd" in importlib.machinery.EXTENSION_SUFFIXES else ""
filename = "%s%d%d%s.dll" % (
modname,
sys.version_info.major,
sys.version_info.minor,
suffix,
)
filename = os.path.join(lib_dir, "pywin32_system32", filename)
loader = importlib.machinery.ExtensionFileLoader(modname, filename)
spec = importlib.machinery.ModuleSpec(name=modname, loader=loader, origin=filename)
mod = importlib.util.module_from_spec(spec)
loader.exec_module(mod)
def SetPyKeyVal(key_name, value_name, value):
root_hkey = get_root_hkey()
root_key = winreg.OpenKey(root_hkey, root_key_name)
try:
my_key = winreg.CreateKey(root_key, key_name)
try:
winreg.SetValueEx(my_key, value_name, 0, winreg.REG_SZ, value)
if verbose:
print(f"-> {root_key_name}\\{key_name}[{value_name}]={value!r}")
finally:
my_key.Close()
finally:
root_key.Close()
def UnsetPyKeyVal(key_name, value_name, delete_key=False):
root_hkey = get_root_hkey()
root_key = winreg.OpenKey(root_hkey, root_key_name)
try:
my_key = winreg.OpenKey(root_key, key_name, 0, winreg.KEY_SET_VALUE)
try:
winreg.DeleteValue(my_key, value_name)
if verbose:
print(f"-> DELETE {root_key_name}\\{key_name}[{value_name}]")
finally:
my_key.Close()
if delete_key:
winreg.DeleteKey(root_key, key_name)
if verbose:
print(f"-> DELETE {root_key_name}\\{key_name}")
except OSError as why:
winerror = getattr(why, "winerror", why.errno)
if winerror != 2: # file not found
raise
finally:
root_key.Close()
def RegisterCOMObjects(register=True):
import win32com.server.register
if register:
func = win32com.server.register.RegisterClasses
else:
func = win32com.server.register.UnregisterClasses
flags = {}
if not verbose:
flags["quiet"] = 1
for module, klass_name in com_modules:
__import__(module)
mod = sys.modules[module]
flags["finalize_register"] = getattr(mod, "DllRegisterServer", None)
flags["finalize_unregister"] = getattr(mod, "DllUnregisterServer", None)
klass = getattr(mod, klass_name)
func(klass, **flags)
def RegisterHelpFile(register=True, lib_dir=None):
if lib_dir is None:
lib_dir = sysconfig.get_paths()["platlib"]
if register:
# Register the .chm help file.
chm_file = os.path.join(lib_dir, "PyWin32.chm")
if os.path.isfile(chm_file):
# This isn't recursive, so if 'Help' doesn't exist, we croak
SetPyKeyVal("Help", None, None)
SetPyKeyVal("Help\\Pythonwin Reference", None, chm_file)
return chm_file
else:
print("NOTE: PyWin32.chm can not be located, so has not been registered")
else:
UnsetPyKeyVal("Help\\Pythonwin Reference", None, delete_key=True)
return None
def RegisterPythonwin(register=True, lib_dir=None):
"""Add (or remove) Pythonwin to context menu for python scripts.
??? Should probably also add Edit command for pys files also.
Also need to remove these keys on uninstall, but there's no function
to add registry entries to uninstall log ???
"""
import os
if lib_dir is None:
lib_dir = sysconfig.get_paths()["platlib"]
classes_root = get_root_hkey()
## Installer executable doesn't seem to pass anything to postinstall script indicating if it's a debug build
pythonwin_exe = os.path.join(lib_dir, "Pythonwin", "Pythonwin.exe")
pythonwin_edit_command = pythonwin_exe + ' -edit "%1"'
keys_vals = [
(
"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Pythonwin.exe",
"",
pythonwin_exe,
),
(
"Software\\Classes\\Python.File\\shell\\Edit with Pythonwin",
"command",
pythonwin_edit_command,
),
(
"Software\\Classes\\Python.NoConFile\\shell\\Edit with Pythonwin",
"command",
pythonwin_edit_command,
),
]
try:
if register:
for key, sub_key, val in keys_vals:
## Since winreg only uses the character Api functions, this can fail if Python
## is installed to a path containing non-ascii characters
hkey = winreg.CreateKey(classes_root, key)
if sub_key:
hkey = winreg.CreateKey(hkey, sub_key)
winreg.SetValueEx(hkey, None, 0, winreg.REG_SZ, val)
hkey.Close()
else:
for key, sub_key, val in keys_vals:
try:
if sub_key:
hkey = winreg.OpenKey(classes_root, key)
winreg.DeleteKey(hkey, sub_key)
hkey.Close()
winreg.DeleteKey(classes_root, key)
except OSError as why:
winerror = getattr(why, "winerror", why.errno)
if winerror != 2: # file not found
raise
finally:
# tell windows about the change
from win32com.shell import shell, shellcon
shell.SHChangeNotify(
shellcon.SHCNE_ASSOCCHANGED, shellcon.SHCNF_IDLIST, None, None
)
def get_shortcuts_folder():
if get_root_hkey() == winreg.HKEY_LOCAL_MACHINE:
try:
fldr = get_special_folder_path("CSIDL_COMMON_PROGRAMS")
except OSError:
# No CSIDL_COMMON_PROGRAMS on this platform
fldr = get_special_folder_path("CSIDL_PROGRAMS")
else:
# non-admin install - always goes in this user's start menu.
fldr = get_special_folder_path("CSIDL_PROGRAMS")
try:
install_group = winreg.QueryValue(
get_root_hkey(), root_key_name + "\\InstallPath\\InstallGroup"
)
except OSError:
install_group = "Python %d.%d" % (
sys.version_info.major,
sys.version_info.minor,
)
return os.path.join(fldr, install_group)
# Get the system directory, which may be the Wow64 directory if we are a 32bit
# python on a 64bit OS.
def get_system_dir():
import win32api # we assume this exists.
try:
import pythoncom
import win32process
from win32com.shell import shell, shellcon
try:
if win32process.IsWow64Process():
return shell.SHGetSpecialFolderPath(0, shellcon.CSIDL_SYSTEMX86)
return shell.SHGetSpecialFolderPath(0, shellcon.CSIDL_SYSTEM)
except (pythoncom.com_error, win32process.error):
return win32api.GetSystemDirectory()
except ImportError:
return win32api.GetSystemDirectory()
def fixup_dbi():
# We used to have a dbi.pyd with our .pyd files, but now have a .py file.
# If the user didn't uninstall, they will find the .pyd which will cause
# problems - so handle that.
import win32api
import win32con
pyd_name = os.path.join(os.path.dirname(win32api.__file__), "dbi.pyd")
pyd_d_name = os.path.join(os.path.dirname(win32api.__file__), "dbi_d.pyd")
py_name = os.path.join(os.path.dirname(win32con.__file__), "dbi.py")
for this_pyd in (pyd_name, pyd_d_name):
this_dest = this_pyd + ".old"
if os.path.isfile(this_pyd) and os.path.isfile(py_name):
try:
if os.path.isfile(this_dest):
print(
f"Old dbi '{this_dest}' already exists - deleting '{this_pyd}'"
)
os.remove(this_pyd)
else:
os.rename(this_pyd, this_dest)
print(f"renamed '{this_pyd}'->'{this_pyd}.old'")
except OSError as exc:
print(f"FAILED to rename '{this_pyd}': {exc}")
def install(lib_dir):
import traceback
# The .pth file is now installed as a regular file.
# Create the .pth file in the site-packages dir, and use only relative paths
# We used to write a .pth directly to sys.prefix - clobber it.
if os.path.isfile(os.path.join(sys.prefix, "pywin32.pth")):
os.unlink(os.path.join(sys.prefix, "pywin32.pth"))
# The .pth may be new and therefore not loaded in this session.
# Setup the paths just in case.
for name in "win32 win32\\lib Pythonwin".split():
sys.path.append(os.path.join(lib_dir, name))
# It is possible people with old versions installed with still have
# pywintypes and pythoncom registered. We no longer need this, and stale
# entries hurt us.
for name in "pythoncom pywintypes".split():
keyname = "Software\\Python\\PythonCore\\" + sys.winver + "\\Modules\\" + name
for root in winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER:
try:
winreg.DeleteKey(root, keyname + "\\Debug")
except OSError:
pass
try:
winreg.DeleteKey(root, keyname)
except OSError:
pass
LoadSystemModule(lib_dir, "pywintypes")
LoadSystemModule(lib_dir, "pythoncom")
import win32api
# and now we can get the system directory:
files = glob.glob(os.path.join(lib_dir, "pywin32_system32\\*.*"))
if not files:
raise RuntimeError("No system files to copy!!")
# Try the system32 directory first - if that fails due to "access denied",
# it implies a non-admin user, and we use sys.prefix
for dest_dir in [get_system_dir(), sys.prefix]:
# and copy some files over there
worked = 0
try:
for fname in files:
base = os.path.basename(fname)
dst = os.path.join(dest_dir, base)
CopyTo("installing %s" % base, fname, dst)
if verbose:
print(f"Copied {base} to {dst}")
worked = 1
# Nuke any other versions that may exist - having
# duplicates causes major headaches.
bad_dest_dirs = [
os.path.join(sys.prefix, "Library\\bin"),
os.path.join(sys.prefix, "Lib\\site-packages\\win32"),
]
if dest_dir != sys.prefix:
bad_dest_dirs.append(sys.prefix)
for bad_dest_dir in bad_dest_dirs:
bad_fname = os.path.join(bad_dest_dir, base)
if os.path.exists(bad_fname):
# let exceptions go here - delete must succeed
os.unlink(bad_fname)
if worked:
break
except win32api.error as details:
if details.winerror == 5:
# access denied - user not admin - try sys.prefix dir,
# but first check that a version doesn't already exist
# in that place - otherwise that one will still get used!
if os.path.exists(dst):
msg = (
"The file '%s' exists, but can not be replaced "
"due to insufficient permissions. You must "
"reinstall this software as an Administrator" % dst
)
print(msg)
raise RuntimeError(msg)
continue
raise
else:
raise RuntimeError(
"You don't have enough permissions to install the system files"
)
# Register our demo COM objects.
try:
try:
RegisterCOMObjects()
except win32api.error as details:
if details.winerror != 5: # ERROR_ACCESS_DENIED
raise
print("You do not have the permissions to install COM objects.")
print("The sample COM objects were not registered.")
except Exception:
print("FAILED to register the Python COM objects")
traceback.print_exc()
# There may be no main Python key in HKCU if, eg, an admin installed
# python itself.
winreg.CreateKey(get_root_hkey(), root_key_name)
chm_file = None
try:
chm_file = RegisterHelpFile(True, lib_dir)
except Exception:
print("Failed to register help file")
traceback.print_exc()
else:
if verbose:
print("Registered help file")
# misc other fixups.
fixup_dbi()
# Register Pythonwin in context menu
try:
RegisterPythonwin(True, lib_dir)
except Exception:
print("Failed to register pythonwin as editor")
traceback.print_exc()
else:
if verbose:
print("Pythonwin has been registered in context menu")
# Create the win32com\gen_py directory.
make_dir = os.path.join(lib_dir, "win32com", "gen_py")
if not os.path.isdir(make_dir):
if verbose:
print(f"Creating directory {make_dir}")
os.mkdir(make_dir)
try:
# create shortcuts
# CSIDL_COMMON_PROGRAMS only available works on NT/2000/XP, and
# will fail there if the user has no admin rights.
fldr = get_shortcuts_folder()
# If the group doesn't exist, then we don't make shortcuts - its
# possible that this isn't a "normal" install.
if os.path.isdir(fldr):
dst = os.path.join(fldr, "PythonWin.lnk")
create_shortcut(
os.path.join(lib_dir, "Pythonwin\\Pythonwin.exe"),
"The Pythonwin IDE",
dst,
"",
sys.prefix,
)
if verbose:
print("Shortcut for Pythonwin created")
# And the docs.
if chm_file:
dst = os.path.join(fldr, "Python for Windows Documentation.lnk")
doc = "Documentation for the PyWin32 extensions"
create_shortcut(chm_file, doc, dst)
if verbose:
print("Shortcut to documentation created")
else:
if verbose:
print(f"Can't install shortcuts - {fldr!r} is not a folder")
except Exception as details:
print(details)
# importing win32com.client ensures the gen_py dir created - not strictly
# necessary to do now, but this makes the installation "complete"
try:
import win32com.client # noqa
except ImportError:
# Don't let this error sound fatal
pass
print("The pywin32 extensions were successfully installed.")
def uninstall(lib_dir):
# First ensure our system modules are loaded from pywin32_system, so
# we can remove the ones we copied...
LoadSystemModule(lib_dir, "pywintypes")
LoadSystemModule(lib_dir, "pythoncom")
try:
RegisterCOMObjects(False)
except Exception as why:
print(f"Failed to unregister COM objects: {why}")
try:
RegisterHelpFile(False, lib_dir)
except Exception as why:
print(f"Failed to unregister help file: {why}")
else:
if verbose:
print("Unregistered help file")
try:
RegisterPythonwin(False, lib_dir)
except Exception as why:
print(f"Failed to unregister Pythonwin: {why}")
else:
if verbose:
print("Unregistered Pythonwin")
try:
# remove gen_py directory.
gen_dir = os.path.join(lib_dir, "win32com", "gen_py")
if os.path.isdir(gen_dir):
shutil.rmtree(gen_dir)
if verbose:
print(f"Removed directory {gen_dir}")
# Remove pythonwin compiled "config" files.
pywin_dir = os.path.join(lib_dir, "Pythonwin", "pywin")
for fname in glob.glob(os.path.join(pywin_dir, "*.cfc")):
os.remove(fname)
# The dbi.pyd.old files we may have created.
try:
os.remove(os.path.join(lib_dir, "win32", "dbi.pyd.old"))
except OSError:
pass
try:
os.remove(os.path.join(lib_dir, "win32", "dbi_d.pyd.old"))
except OSError:
pass
except Exception as why:
print(f"Failed to remove misc files: {why}")
try:
fldr = get_shortcuts_folder()
for link in ("PythonWin.lnk", "Python for Windows Documentation.lnk"):
fqlink = os.path.join(fldr, link)
if os.path.isfile(fqlink):
os.remove(fqlink)
if verbose:
print(f"Removed {link}")
except Exception as why:
print(f"Failed to remove shortcuts: {why}")
# Now remove the system32 files.
files = glob.glob(os.path.join(lib_dir, "pywin32_system32\\*.*"))
# Try the system32 directory first - if that fails due to "access denied",
# it implies a non-admin user, and we use sys.prefix
try:
for dest_dir in [get_system_dir(), sys.prefix]:
# and copy some files over there
worked = 0
for fname in files:
base = os.path.basename(fname)
dst = os.path.join(dest_dir, base)
if os.path.isfile(dst):
try:
os.remove(dst)
worked = 1
if verbose:
print("Removed file %s" % (dst))
except Exception:
print(f"FAILED to remove {dst}")
if worked:
break
except Exception as why:
print(f"FAILED to remove system files: {why}")
# NOTE: This used to be run from inside the bdist_wininst created binary un/installer.
# From inside the binary installer this script HAD to NOT
# call sys.exit() or raise SystemExit, otherwise the installer would also terminate!
# Out of principle, we're still not using system exits.
def verify_destination(location: str) -> str:
location = os.path.abspath(location)
if not os.path.isdir(location):
raise argparse.ArgumentTypeError(
f'Path "{location}" is not an existing directory!'
)
return location
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""A post-install script for the pywin32 extensions.
* Typical usage:
> python -m pywin32_postinstall -install
* or (shorter but you don't have control over which python environment is used)
> pywin32_postinstall -install
You need to execute this script, with a '-install' parameter,
to ensure the environment is setup correctly to install COM objects, services, etc.
""",
)
parser.add_argument(
"-install",
default=False,
action="store_true",
help="Configure the Python environment correctly for pywin32.",
)
parser.add_argument(
"-remove",
default=False,
action="store_true",
help="Try and remove everything that was installed or copied.",
)
parser.add_argument(
"-wait",
type=int,
help="Wait for the specified process to terminate before starting.",
)
parser.add_argument(
"-silent",
default=False,
action="store_true",
help='Don\'t display the "Abort/Retry/Ignore" dialog for files in use.',
)
parser.add_argument(
"-quiet",
default=False,
action="store_true",
help="Don't display progress messages.",
)
parser.add_argument(
"-destination",
default=sysconfig.get_paths()["platlib"],
type=verify_destination,
help="Location of the PyWin32 installation",
)
args = parser.parse_args()
if not args.quiet:
print(f"Parsed arguments are: {args}")
if not args.install ^ args.remove:
parser.error("You need to either choose to -install or -remove!")
if args.wait is not None:
try:
os.waitpid(args.wait, 0)
except OSError:
# child already dead
pass
silent = args.silent
verbose = not args.quiet
if args.install:
install(args.destination)
if args.remove:
uninstall(args.destination)
if __name__ == "__main__":
main()

Binary file not shown.

View File

@@ -0,0 +1,120 @@
"""A test runner for pywin32"""
import os
import site
import subprocess
import sys
# locate the dirs based on where this script is - it may be either in the
# source tree, or in an installed Python 'Scripts' tree.
project_root = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
site_packages = [site.getusersitepackages()] + site.getsitepackages()
failures = []
# Run a test using subprocess and wait for the result.
# If we get an returncode != 0, we know that there was an error, but we don't
# abort immediately - we run as many tests as we can.
def run_test(script, cmdline_extras):
dirname, scriptname = os.path.split(script)
# some tests prefer to be run from their directory.
cmd = [sys.executable, "-u", scriptname] + cmdline_extras
print("--- Running '%s' ---" % script)
sys.stdout.flush()
result = subprocess.run(cmd, check=False, cwd=dirname)
print(f"*** Test script '{script}' exited with {result.returncode}")
sys.stdout.flush()
if result.returncode:
failures.append(script)
def find_and_run(possible_locations, extras):
for maybe in possible_locations:
if os.path.isfile(maybe):
run_test(maybe, extras)
break
else:
raise RuntimeError(
"Failed to locate a test script in one of %s" % possible_locations
)
def main():
import argparse
code_directories = [project_root] + site_packages
parser = argparse.ArgumentParser(
description="A script to trigger tests in all subprojects of PyWin32."
)
parser.add_argument(
"-no-user-interaction",
default=False,
action="store_true",
help="(This is now the default - use `-user-interaction` to include them)",
)
parser.add_argument(
"-user-interaction",
action="store_true",
help="Include tests which require user interaction",
)
parser.add_argument(
"-skip-adodbapi",
default=False,
action="store_true",
help="Skip the adodbapi tests; useful for CI where there's no provider",
)
args, remains = parser.parse_known_args()
# win32, win32ui / Pythonwin
extras = []
if args.user_interaction:
extras.append("-user-interaction")
extras.extend(remains)
scripts = [
"win32/test/testall.py",
"Pythonwin/pywin/test/all.py",
]
for script in scripts:
maybes = [os.path.join(directory, script) for directory in code_directories]
find_and_run(maybes, extras)
# win32com
maybes = [
os.path.join(directory, "win32com", "test", "testall.py")
for directory in [os.path.join(project_root, "com")] + site_packages
]
extras = remains + ["1"] # only run "level 1" tests in CI
find_and_run(maybes, extras)
# adodbapi
if not args.skip_adodbapi:
maybes = [
os.path.join(directory, "adodbapi", "test", "adodbapitest.py")
for directory in code_directories
]
find_and_run(maybes, remains)
# This script has a hard-coded sql server name in it, (and markh typically
# doesn't have a different server to test on) but there is now supposed to be a server out there on the Internet
# just to run these tests, so try it...
maybes = [
os.path.join(directory, "adodbapi", "test", "test_adodbapi_dbapi20.py")
for directory in code_directories
]
find_and_run(maybes, remains)
if failures:
print("The following scripts failed")
for failure in failures:
print(">", failure)
sys.exit(1)
print("All tests passed \\o/")
if __name__ == "__main__":
main()

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.