First wheel package version.
parent
6533bf52f6
commit
97938ccde1
@ -1,8 +1,6 @@
|
||||
build
|
||||
dist
|
||||
dist_installer
|
||||
docs/*.html
|
||||
docs/index.htm
|
||||
/build
|
||||
/Net2Scripting.egg-info
|
||||
/dist/*.tar.gz
|
||||
*.pyc
|
||||
#*#
|
||||
*~
|
||||
|
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2018
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,29 @@
|
||||
"""
|
||||
Main program for Net2Scripting.
|
||||
Basically just intializes the log4net.
|
||||
"""
|
||||
import sys
|
||||
import Net2Scripting.settings
|
||||
|
||||
|
||||
def init_logging(config_file=None):
|
||||
"""Init logging
|
||||
"""
|
||||
# If no config file is given, use the default
|
||||
if not config_file:
|
||||
config_file = settings.CONFIG_FILE
|
||||
|
||||
# Setup logging first
|
||||
from Net2Scripting.pylog4net import Log4Net
|
||||
try:
|
||||
Log4Net.read_config(config_file)
|
||||
except Exception as e:
|
||||
print('Log error: %s' % (str(e)))
|
||||
sys.exit(1)
|
||||
|
||||
from Net2Scripting.config import Config
|
||||
try:
|
||||
cfg = Config(settings.CONFIG_FILE)
|
||||
except Exception as e:
|
||||
print('Config error: %s' % (str(e)))
|
||||
sys.exit(1)
|
@ -0,0 +1,3 @@
|
||||
"""
|
||||
The module that offers several Net2 related network utilities
|
||||
"""
|
@ -0,0 +1,9 @@
|
||||
import os
|
||||
|
||||
BASE_DIR = os.path.dirname(__file__)
|
||||
|
||||
# Default config file to use for dotnet stuff
|
||||
CONFIG_FILE = os.path.join(BASE_DIR, 'Net2Scripting.config')
|
||||
|
||||
# Generic lib dir
|
||||
LIB_DIR = os.path.join(BASE_DIR, 'libs')
|
@ -1,10 +0,0 @@
|
||||
@echo off
|
||||
del dist_installer\* /s/q > nul
|
||||
|
||||
rem taskkill /IM explorer.exe /F
|
||||
rem cd /d %userprofile%\AppData\Local
|
||||
rem del IconCache.db /a
|
||||
rem start explorer.exe
|
||||
|
||||
"C:\Program Files\Inno Setup 5\ISCC.exe" inno_script.iss
|
||||
pause
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
@ -1,121 +0,0 @@
|
||||
Net2Scripting
|
||||
=============
|
||||
|
||||
The Net2Scripting program is an add-on for the Paxton Net2 software.
|
||||
It offers the possibility to run Python scripts against the Net2 SDK or
|
||||
straight against the Net2 database.
|
||||
Using the SDK, you can access remote Net2 servers. Using the direct database
|
||||
interface, only local access is possible.
|
||||
|
||||
Scripting allows ad-hoc functionality to be created, without compilation.
|
||||
Useful for proof of concepts, filling Net2 with test data, simple door
|
||||
control, Net2 data exports, etc.
|
||||
|
||||
REQUIREMENTS
|
||||
* A PC running a recent Windows version. The software has been tested on
|
||||
WinXP(SP3), Win7 and Win8.
|
||||
* Administrator rights.
|
||||
* The Net2 V5.1 or higher software package.
|
||||
|
||||
INSTALLATION
|
||||
* Run the installer program, which will create an IntoAccess folder in the
|
||||
Programs menu with a shortcut to Net2Scripting, install the executable,
|
||||
libraries, samples and documentation.
|
||||
* Optionally edit the Net2Scripting.exe.config file that can be found in the
|
||||
program installation folder.
|
||||
(by default it contains a reference to a sample script
|
||||
'samples/user_script.py')
|
||||
|
||||
USAGE
|
||||
* Option 1: Edit the Net2Scripting.exe.config file, changing the
|
||||
'user_script' setting to point to your script. Run the Net2Scripting
|
||||
program.
|
||||
* Option 2: Edit the Net2Scripting.exe.config file, adding more entries to
|
||||
the 'appSetting' section. Run the Net2Scripting program adding the parameter
|
||||
/k=<keyword>, where <keyword> points to the script you want to execute.
|
||||
* Option 3: Run the Net2Scripting program, adding the path to the script you
|
||||
wish to execute as parameter.
|
||||
* If you run the Net2Scripting using the explorer, you may want the window
|
||||
containing the script result to remain open. Set the appSetting
|
||||
'confirm_wait' to 'true' to have it wait for the <enter> key before closing.
|
||||
If you want to run a script using a scheduler, set this option to 'false'.
|
||||
* By default, the application logs fairly much and both to the console as
|
||||
well as to a (rolling) file. Change the root 'level' value from DEBUG to
|
||||
INFO, WARN, ERROR or FATAL to make it less verbose. You can add or remove
|
||||
any log4net conpatible log appenders to suit your needs.
|
||||
Beware that the scripting program locks the log file, so if you run more
|
||||
than one instance, it will complain about not being able to log.
|
||||
|
||||
DOCUMENTATION / HELP
|
||||
* Some pydoc generated 'help' for the API is placed in the 'docs'
|
||||
subdirectory of the installation folder. It does not hurt however to also
|
||||
keep the Net2 API doc at hand while scripting.
|
||||
* A number of script samples are provided, meant for those with some basic
|
||||
knowledge of Python. For a full Python language reference, check out
|
||||
http://www.python.org/doc/
|
||||
Not all Net2 SDK functions are available through the python api yet.
|
||||
If you would like to add stuff however, check out the'inheritance.py'
|
||||
sample to get you started.
|
||||
* The (free) Net2Query tool, available at http://www.intoaccess.com, can
|
||||
also of use to get some insight on available tables, column names and
|
||||
data types.
|
||||
|
||||
BACKGROUND
|
||||
* Originally created by CRC Value.
|
||||
* Maintained (sort of) by IntoAccess from July 2017 - May 2018.
|
||||
* Open source from May 2018 onward.
|
||||
* The package websites:
|
||||
- http://www.net2scripting.nl
|
||||
- https://github.com/cor-kalis/Net2Scripting
|
||||
|
||||
ACKNOWLEDGEMENTS
|
||||
* The Net2Scripting program is created using the following libraries/tools:
|
||||
- Python => http://www.python.org
|
||||
- Python.Net => http://pythonnet.sourceforge.net
|
||||
- Py2exe => http://www.py2exe.org
|
||||
- Paxton.Net2.OEMClientLibrary => http://www.paxton.co.uk
|
||||
- Inno Setup => http://www.jrsoftware.org
|
||||
|
||||
LICENSE
|
||||
* MIT
|
||||
|
||||
DISCLAIMER
|
||||
* You will use this software at your own risk. No responsibility is accepted for
|
||||
any damage it may accidentally cause.
|
||||
|
||||
HISTORY
|
||||
* V1.0 was published in April 2013. Initial version
|
||||
* V1.1 was published in July 2013.
|
||||
- Fixes a module scope issue (imported modules not recognized in functions).
|
||||
- User image manipulation.
|
||||
- Confirm wait, even on a sys.exit().
|
||||
- Allow remote native db access.
|
||||
- Net2Plus module detection using udp broadcasts.
|
||||
- SQLServer detection using udp broadcasts.
|
||||
- Default values for add_user and modify_user (less hassle).
|
||||
* V1.2 was published in July 2013.
|
||||
- Enable linecache.getline by default, so 'list' in pdb.set_trace() shows
|
||||
something useful. (disable in config by setting 'linecache_enable' to false)
|
||||
- Added __scripting_version__ var, to test script compatibility.
|
||||
- Fixed bug in Net2XS.deactivate_user fuction.
|
||||
* V1.3 was published in September 2013.
|
||||
- Fix / implement acu monitoring
|
||||
- Fix get_users / get_user_by_id bug
|
||||
* V1.4 was published in October 2013.
|
||||
- Fix password encryption on remote native database connection
|
||||
* V2.0 was published in April 2014.
|
||||
- Net2 V5 compatible.
|
||||
* V2.1 was published in July 2014.
|
||||
- Fix hard coded event and subtype bug in add_event_record.
|
||||
* V2.2 was published in October 2014.
|
||||
- Removed misplaced delete_image parameter in add_user
|
||||
* V2.3 was published in December 2015.
|
||||
- Upgraded to Python 2.7.10 and included most standard Python modules.
|
||||
* V2.4 was published in August 2016.
|
||||
- Added the option to use either a dotnet or python date time objects for
|
||||
the add_user and modify_user methods.
|
||||
- Added delete_card and get_cards methods.
|
||||
* V3.0 was published in August 2017.
|
||||
- Upgrade to Python 3.4.4
|
||||
* V4.0 was published in May 2018.
|
||||
- Made open source.
|
@ -1,47 +0,0 @@
|
||||
; Script generated by the Inno Setup Script Wizard.
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "Net2Scripting"
|
||||
#define MyAppVersion "4.0"
|
||||
#define MyAppPublisher "Net2Scripting"
|
||||
#define MyAppURL "http://www.net2scripting.nl/"
|
||||
|
||||
[Setup]
|
||||
; NOTE: The value of AppId uniquely identifies this application.
|
||||
; Do not use the same AppId value in installers for other applications.
|
||||
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
|
||||
AppId={{3940C8D4-5D5F-43CF-B92E-4086ED2198B2}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
;AppVerName={#MyAppName} {#MyAppVersion}
|
||||
AppPublisher={#MyAppPublisher}
|
||||
AppPublisherURL={#MyAppURL}
|
||||
AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
DefaultDirName={pf}\Paxton Access/{#MyAppName}
|
||||
DefaultGroupName=Paxton Access
|
||||
InfoAfterFile=.\dist\docs\README.txt
|
||||
OutputDir=.\dist_installer
|
||||
OutputBaseFilename=SetupNet2Scripting
|
||||
SetupIconFile=.\dist\resources\Net2Scripting.ico
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||
|
||||
[Files]
|
||||
Source: ".\dist\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\Net2Scripting"; Filename: "{app}\{#MyAppName}.exe"
|
||||
Name: "{group}\Net2Scripting API"; Filename: "{app}\docs\index.htm"
|
||||
Name: "{commondesktop}\Net2Scripting"; Filename: "{app}\{#MyAppName}.exe"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
|
||||
[UninstallRun]
|
@ -1,21 +0,0 @@
|
||||
@echo off
|
||||
|
||||
echo --- Cleaning...
|
||||
del build\* /s/q > nul
|
||||
del dist\* /s/q > nul
|
||||
del docs\*.html /s/q > nul
|
||||
echo --- Cleaning done
|
||||
|
||||
echo --- Generating docs
|
||||
cd src
|
||||
c:/WinPrg/Python34/python docgen.py
|
||||
cd ..
|
||||
echo --- Generating docs done
|
||||
|
||||
echo --- Building executable
|
||||
cd src
|
||||
c:/WinPrg/Python34/python setup.py py2exe
|
||||
cd ..
|
||||
echo --- Building executable done
|
||||
|
||||
pause
|
Binary file not shown.
Before Width: | Height: | Size: 320 KiB |
@ -1,6 +0,0 @@
|
||||
@echo off
|
||||
cd src
|
||||
:again
|
||||
c:\WinPrg\Python34\python Net2Scripting.py %1
|
||||
pause
|
||||
goto again
|
Binary file not shown.
@ -0,0 +1,43 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||
</configSections>
|
||||
<appSettings>
|
||||
<add key="user_script" value="samples/user_script.py" />
|
||||
<add key="confirm_wait" value="true" />
|
||||
<add key="log_stacktrace" value="true" />
|
||||
<add key="enable_linecache" value="true" />
|
||||
</appSettings>
|
||||
<log4net>
|
||||
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
|
||||
<param name="File" value="${SystemDrive}/Net2 Access Control/Net2Scripting.log"/>
|
||||
<param name="AppendToFile" value="true"/>
|
||||
<param name="rollingStyle" value="Size"/>
|
||||
<param name="maxSizeRollBackups" value="10"/>
|
||||
<param name="maximumFileSize" value="10MB"/>
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<param name="Header" value=""/>
|
||||
<param name="Footer" value=""/>
|
||||
<param name="ConversionPattern" value="%d [%c,%t] %-5p %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<param name="Header" value="[Header]\r\n" />
|
||||
<param name="Footer" value="[Footer]\r\n" />
|
||||
<param name="ConversionPattern" value="%d [%c,%t] %-5p %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="RollingFileAppender" />
|
||||
<appender-ref ref="ConsoleAppender" />
|
||||
</root>
|
||||
<logger name="Paxton">
|
||||
<level value="ERROR" />
|
||||
<appender-ref ref="RollingFileAppender" />
|
||||
<appender-ref ref="ConsoleAppender" />
|
||||
</logger>
|
||||
</log4net>
|
||||
</configuration>
|
@ -0,0 +1,30 @@
|
||||
import setuptools
|
||||
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
setuptools.setup(
|
||||
name="Net2Scripting",
|
||||
version="5.0.0",
|
||||
author="Cor Kalis",
|
||||
author_email="info@net2scripting.nl",
|
||||
description="Python scripting for Paxton Net2",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/cor-kalis/Net2Scripting",
|
||||
packages=setuptools.find_packages(),
|
||||
install_requires=[
|
||||
'pythonnet'
|
||||
],
|
||||
package_data={
|
||||
'': ['libs/log4netdll/*.dll',
|
||||
'libs/paxton/*.dll',
|
||||
'Net2Scripting.config'
|
||||
]
|
||||
},
|
||||
classifiers=(
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: Microsoft :: Windows",
|
||||
)
|
||||
)
|
@ -1,329 +0,0 @@
|
||||
"""
|
||||
Main program for Net2Scripting.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import settings
|
||||
import traceback
|
||||
|
||||
# This is just to force py2exe to include these packages
|
||||
if False == True:
|
||||
import net2xs
|
||||
import net2dbxs
|
||||
import network
|
||||
# Not required but nice to have
|
||||
import abc
|
||||
import aifc
|
||||
import antigravity
|
||||
import argparse
|
||||
import ast
|
||||
import asynchat
|
||||
import asyncio
|
||||
import asyncore
|
||||
import base64
|
||||
import bdb
|
||||
import binhex
|
||||
import bisect
|
||||
import bz2
|
||||
import cProfile
|
||||
import calendar
|
||||
import cgi
|
||||
import cgitb
|
||||
import chunk
|
||||
import cmd
|
||||
import code
|
||||
import codecs
|
||||
import codeop
|
||||
import collections
|
||||
import colorsys
|
||||
import compileall
|
||||
import concurrent
|
||||
import configparser
|
||||
import contextlib
|
||||
import copy
|
||||
import copyreg
|
||||
# import crypt
|
||||
import csv
|
||||
import ctypes
|
||||
# import curses
|
||||
import datetime
|
||||
# import dbm
|
||||
import decimal
|
||||
import difflib
|
||||
import dis
|
||||
import distutils
|
||||
import doctest
|
||||
import threading
|
||||
import email
|
||||
import encodings
|
||||
# import ensurepip
|
||||
import enum
|
||||
import filecmp
|
||||
import fileinput
|
||||
import fnmatch
|
||||
import formatter
|
||||
import fractions
|
||||
import ftplib
|
||||
import functools
|
||||
import genericpath
|
||||
import getopt
|
||||
import getpass
|
||||
import gettext
|
||||
import glob
|
||||
import gzip
|
||||
import hashlib
|
||||
import heapq
|
||||
import hmac
|
||||
import html
|
||||
import http
|
||||
import idlelib
|
||||
import imaplib
|
||||
import imghdr
|
||||
import imp
|
||||
import importlib
|
||||
import inspect
|
||||
import io
|
||||
import ipaddress
|
||||
import json
|
||||
import keyword
|
||||
import lib2to3
|
||||
import linecache
|
||||
import locale
|
||||
import logging
|
||||
import lzma
|
||||
# import macpath
|
||||
# import macurl2path
|
||||
import mailbox
|
||||
import mailcap
|
||||
import mimetypes
|
||||
import modulefinder
|
||||
import msilib
|
||||
# import multiprocessing
|
||||
import netrc
|
||||
import nntplib
|
||||
import ntpath
|
||||
import nturl2path
|
||||
import numbers
|
||||
import opcode
|
||||
import operator
|
||||
import optparse
|
||||
import os
|
||||
import pathlib
|
||||
import pdb
|
||||
import pickle
|
||||
import pickletools
|
||||
import pipes
|
||||
import pkgutil
|
||||
import platform
|
||||
import plistlib
|
||||
import poplib
|
||||
import posixpath
|
||||
import pprint
|
||||
import profile
|
||||
import pstats
|
||||
import pty
|
||||
import pyclbr
|
||||
import pydoc
|
||||
import pydoc_data
|
||||
import queue
|
||||
import quopri
|
||||
import random
|
||||
import re
|
||||
import reprlib
|
||||
import rlcompleter
|
||||
import runpy
|
||||
import sched
|
||||
import selectors
|
||||
import shelve
|
||||
import shlex
|
||||
import shutil
|
||||
import site
|
||||
# import smtpd
|
||||
import smtplib
|
||||
import sndhdr
|
||||
import socket
|
||||
import socketserver
|
||||
import sqlite3
|
||||
# import compile
|
||||
# import constants
|
||||
# import parse
|
||||
import ssl
|
||||
import stat
|
||||
import statistics
|
||||
import string
|
||||
import stringprep
|
||||
import struct
|
||||
import subprocess
|
||||
import sunau
|
||||
import symbol
|
||||
import symtable
|
||||
import sysconfig
|
||||
import tabnanny
|
||||
import tarfile
|
||||
import telnetlib
|
||||
import tempfile
|
||||
import test
|
||||
import textwrap
|
||||
import this
|
||||
import threading
|
||||
import timeit
|
||||
import tkinter
|
||||
import token
|
||||
import tokenize
|
||||
import trace
|
||||
import traceback
|
||||
import tracemalloc
|
||||
import tty
|
||||
import turtle
|
||||
import turtledemo
|
||||
import types
|
||||
import unittest
|
||||
import urllib
|
||||
import uu
|
||||
import uuid
|
||||
import venv
|
||||
import warnings
|
||||
import wave
|
||||
import weakref
|
||||
import webbrowser
|
||||
import wsgiref
|
||||
import xdrlib
|
||||
import xml
|
||||
import xmlrpc
|
||||
import zipfile
|
||||
|
||||
|
||||
# Setup logging first
|
||||
from pylog4net import Log4Net
|
||||
try:
|
||||
Log4Net.read_config(settings.CONFIG_FILE)
|
||||
except Exception as e:
|
||||
print('Log error: %s' % (str(e)))
|
||||
sys.exit(1)
|
||||
|
||||
from config import Config
|
||||
try:
|
||||
cfg = Config(settings.CONFIG_FILE)
|
||||
except Exception as e:
|
||||
print('Config error: %s' % (str(e)))
|
||||
sys.exit(1)
|
||||
|
||||
# Running as py2exe: check if linecache should be enabled
|
||||
# if hasattr(sys, 'frozen'):
|
||||
# if cfg.get("enable_linecache", True, bool):
|
||||
# # Monkey patch it back to the original value
|
||||
# import linecache
|
||||
# linecache.getline = linecache.orig_getline
|
||||
# del linecache
|
||||
|
||||
# Log4net logger
|
||||
logger = Log4Net.get_logger('Net2Scripting')
|
||||
|
||||
|
||||
def run(script_file):
|
||||
"""Run script file
|
||||
"""
|
||||
try:
|
||||
if not os.path.isfile(script_file):
|
||||
raise Exception("User script '%s' does not exist!" % (script_file))
|
||||
|
||||
# Get script dir and add it to the module search path
|
||||
sys.path.insert(0, os.path.dirname(script_file))
|
||||
|
||||
print("Press '<ctrl> C' to quit...")
|
||||
logger.Debug("Calling user script '%s'" % (script_file))
|
||||
try:
|
||||
# Strip Net2Scripting param from arguments
|
||||
sys.argv = sys.argv[1:]
|
||||
# Explicitly provide dict, to prevent scope issues
|
||||
with open(script_file) as f:
|
||||
code = compile(f.read(), script_file, 'exec')
|
||||
exec(code,
|
||||
{"__name__": "__main__",
|
||||
"__file__": script_file,
|
||||
"__scripting_version__": settings.VERSION})
|
||||
except KeyboardInterrupt:
|
||||
logger.Debug("User interrupt")
|
||||
|
||||
except Exception as ex:
|
||||
|
||||
msg = "Fatal error: " + str(ex)
|
||||
if cfg.get("log_stacktrace", default=False, vtype=bool):
|
||||
msg += "\n" + traceback.format_exc()
|
||||
logger.Fatal(msg)
|
||||
return 1
|
||||
|
||||
|
||||
def run_key(script_key):
|
||||
"""Run file referenced by setting keyword
|
||||
"""
|
||||
try:
|
||||
script_key = script_key.strip()
|
||||
if not script_key:
|
||||
raise "The provided script keyword is empty!"
|
||||
|
||||
# Fetch setting from config
|
||||
cfg.check_required([(script_key, str)])
|
||||
|
||||
return run(cfg.get(script_key))
|
||||
|
||||
except Exception as ex:
|
||||
logger.Fatal("Fatal error: " + str(ex))
|
||||
return 1
|
||||
|
||||
|
||||
def confirm_wait():
|
||||
"""Wait for user confirmation
|
||||
"""
|
||||
# Fetch setting from config
|
||||
wait = cfg.get("confirm_wait", default=False, vtype=bool)
|
||||
if wait:
|
||||
print()
|
||||
input("Press enter to continue: ")
|
||||
|
||||
|
||||
# Main program entry
|
||||
if __name__ == '__main__':
|
||||
|
||||
ret_val = 0
|
||||
|
||||
try:
|
||||
if len(sys.argv) > 1:
|
||||
arg = sys.argv[1]
|
||||
|
||||
if arg == "/?":
|
||||
print()
|
||||
print("Net2Scripting V%s, by Net2 Solutions" % (settings.VERSION))
|
||||
print()
|
||||
print(" /? = help")
|
||||
print(" /k:keyword = run script referenced by appSettings keyword")
|
||||
print(" <script file path> = run given script")
|
||||
print()
|
||||
print(" By default, the script referenced by the 'user_script' setting is run.")
|
||||
print(" Settings are located in the 'Net2Scripting.exe.config' file.")
|
||||
print(" Also modify this file if you prefer different log settings.")
|
||||
print
|
||||
ret_val = 1
|
||||
|
||||
# Run by keyword
|
||||
elif arg.startswith("/k:"):
|
||||
ret_val = run_key(arg.split(":", 1)[1])
|
||||
|
||||
# Run as file
|
||||
elif not arg.startswith("/"):
|
||||
ret_val = run(arg)
|
||||
|
||||
# Unknown option
|
||||
else:
|
||||
print("Unknown parameter: " + arg)
|
||||
ret_val = 1
|
||||
else:
|
||||
# Run as default
|
||||
ret_val = run_key("user_script")
|
||||
|
||||
finally:
|
||||
# Wait for user confirmation when required
|
||||
confirm_wait()
|
||||
|
||||
# Return with value
|
||||
sys.exit(ret_val)
|
@ -1,78 +0,0 @@
|
||||
"""
|
||||
Helper module to generate the pydoc based
|
||||
"""
|
||||
import os
|
||||
import settings
|
||||
import sys
|
||||
|
||||
from glob import glob
|
||||
from pydoc import writedoc
|
||||
|
||||
# So we can find the libs
|
||||
sys.path.append('libs')
|
||||
|
||||
PACKAGES = ["net2base",
|
||||
"net2xs", "net2xs.conversions", "net2xs.deftypes",
|
||||
"net2dbxs",
|
||||
"network", "network.net2plus", "network.sqlserver"]
|
||||
|
||||
INDEX = "index.htm"
|
||||
|
||||
|
||||
def read_file(file_name):
|
||||
"""Read file content
|
||||
"""
|
||||
with open(file_name) as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def alter_doc(content):
|
||||
"""Change doc content
|
||||
- Strip reference to local python file
|
||||
- Replace index with our own index file
|
||||
"""
|
||||
pos1 = content.find("<a href=\"file:///")
|
||||
if pos1 >= 0:
|
||||
pos2 = content.find("</a>", pos1)
|
||||
content = content[:pos1] + content[pos2 + len("</a>"):]
|
||||
|
||||
content = content.replace('<a href=".">index</a>',
|
||||
'<a href="index.htm">index</a>')
|
||||
return content
|
||||
|
||||
|
||||
def alter_index(content):
|
||||
"""Change index content
|
||||
- Replace version place holder with actual version
|
||||
"""
|
||||
content = content.replace('#VERSION#', settings.VERSION)
|
||||
return content
|
||||
|
||||
|
||||
def write_file(file_name, content):
|
||||
"""Write content as file
|
||||
"""
|
||||
with open(file_name, "w") as f:
|
||||
f.write(content)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# Create docs
|
||||
for p in PACKAGES:
|
||||
writedoc(p)
|
||||
|
||||
# For each html, generated into src, write altered to docs
|
||||
for src in glob("*.html"):
|
||||
dest = '../docs/' + src
|
||||
content = read_file(src)
|
||||
content = alter_doc(content)
|
||||
|
||||
write_file(dest, content)
|
||||
os.remove(src)
|
||||
|
||||
# Write index with correct version to docs
|
||||
content = read_file(INDEX)
|
||||
dest = '../docs/' + INDEX
|
||||
content = alter_index(content)
|
||||
write_file(dest, content)
|
@ -1,29 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body {
|
||||
color: #142313;
|
||||
font-family: Tahoma, sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
text-align: left;
|
||||
color: darkSlateGrey;
|
||||
background-color: #f0f0f8;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<center>
|
||||
<h2>Net2Scripting V#VERSION# API documentation</h2>
|
||||
<br>
|
||||
<img src="Net2Scripting.png">
|
||||
<br>
|
||||
<br>
|
||||
<p><a href="net2xs.html">Net2XS for access through the SDK</a></p>
|
||||
<p><a href="net2dbxs.html">Net2DBXS for direct database access</a></p>
|
||||
<p><a href="network.html">Network tools related to Net2 access</a></p>
|
||||
<p><a href="README.txt">Application README</a></p>
|
||||
<br>
|
||||
<p><h5><a href="http://www.net2scripting.nl">www.net2scripting.nl</a></h5></p>
|
||||
</body>
|
||||
</html>
|
@ -1,8 +0,0 @@
|
||||
"""
|
||||
The module that offers several Net2 related network utilities
|
||||
"""
|
||||
|
||||
# This is just to force py2exe to include these packages
|
||||
if False == True:
|
||||
import network.net2plus
|
||||
import network.sqlserver
|
@ -1,21 +0,0 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Running as py2exe
|
||||
if hasattr(sys, 'frozen'):
|
||||
DEBUG = False
|
||||
BASE_DIR = os.path.split(sys.executable)[0]
|
||||
# Running as interpreter
|
||||
else:
|
||||
DEBUG = True
|
||||
BASE_DIR = '.'
|
||||
|
||||
# Config file to use for dotnet stuff
|
||||
CONFIG_FILE = os.path.join(
|
||||
BASE_DIR, 'Net2Scripting.exe.config')
|
||||
|
||||
# Generic lib dir
|
||||
LIB_DIR = os.path.join(BASE_DIR, 'libs')
|
||||
|
||||
# Version
|
||||
VERSION = '4.0'
|
@ -1,35 +0,0 @@
|
||||
import os
|
||||
|
||||
from distutils.core import setup
|
||||
from glob import glob
|
||||
import py2exe
|
||||
|
||||
# Data files (resources)
|
||||
data_files = [('.', ['Net2Scripting.exe.config']),
|
||||
('.', glob(r'../runtime/*.*')),
|
||||
('libs/log4netdll', glob(r'libs/log4netdll/*.*')),
|
||||
('libs/paxton', glob(r'libs/paxton/*.*')),
|
||||
('resources', glob(r'../resources/*.*')),
|
||||
('docs', glob(r'../docs/*.*')),
|
||||
('samples', glob(r'samples/*.py'))]
|
||||
|
||||
# Source files (python modules)
|
||||
source_files = [os.path.splitext(os.path.basename(f))[0] for f in glob('*.py')]
|
||||
|
||||
setup(
|
||||
# basic console exe
|
||||
console=[{'script': 'Net2Scripting.py',
|
||||
'icon_resources': [(1, '../resources/Net2Scripting.ico')]}],
|
||||
py_modules=source_files,
|
||||
data_files=data_files,
|
||||
# zipfile=None,
|
||||
# options={'py2exe': {'bundle_files': 1, 'compressed': True}}
|
||||
options={
|
||||
'py2exe': {
|
||||
'dist_dir': '../dist',
|
||||
},
|
||||
'build': {
|
||||
'build_base': '../build'
|
||||
}
|
||||
}
|
||||
)
|
Loading…
Reference in New Issue