First wheel package version.
This commit is contained in:
		
							
								
								
									
										8
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,8 +1,6 @@
 | 
				
			|||||||
build
 | 
					/build
 | 
				
			||||||
dist
 | 
					/Net2Scripting.egg-info
 | 
				
			||||||
dist_installer
 | 
					/dist/*.tar.gz
 | 
				
			||||||
docs/*.html
 | 
					 | 
				
			||||||
docs/index.htm
 | 
					 | 
				
			||||||
*.pyc
 | 
					*.pyc
 | 
				
			||||||
#*#
 | 
					#*#
 | 
				
			||||||
*~
 | 
					*~
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							@@ -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.
 | 
				
			||||||
@@ -11,7 +11,7 @@
 | 
				
			|||||||
  </appSettings>
 | 
					  </appSettings>
 | 
				
			||||||
  <log4net>
 | 
					  <log4net>
 | 
				
			||||||
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
 | 
					    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
 | 
				
			||||||
      <param name="File" value="${ALLUSERSPROFILE}/Application Data/IntoAccess/Net2Scripting/Net2Scripting.log"/>
 | 
					      <param name="File" value="${SystemDrive}/Net2 Access Control/Net2Scripting.log"/>
 | 
				
			||||||
      <param name="AppendToFile" value="true"/>
 | 
					      <param name="AppendToFile" value="true"/>
 | 
				
			||||||
      <param name="rollingStyle" value="Size"/>
 | 
					      <param name="rollingStyle" value="Size"/>
 | 
				
			||||||
      <param name="maxSizeRollBackups" value="10"/>
 | 
					      <param name="maxSizeRollBackups" value="10"/>
 | 
				
			||||||
							
								
								
									
										29
									
								
								Net2Scripting/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								Net2Scripting/__init__.py
									
									
									
									
									
										Normal file
									
								
							@@ -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)
 | 
				
			||||||
@@ -10,8 +10,8 @@ clr.AddReference('System.Data')
 | 
				
			|||||||
from System.Data.SqlClient import SqlConnection, SqlDataAdapter, SqlCommand
 | 
					from System.Data.SqlClient import SqlConnection, SqlDataAdapter, SqlCommand
 | 
				
			||||||
from System.Data import DataSet, CommandType, ParameterDirection
 | 
					from System.Data import DataSet, CommandType, ParameterDirection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from net2base import Net2Base
 | 
					from Net2Scripting.net2base import Net2Base
 | 
				
			||||||
from pylog4net import Log4Net
 | 
					from Net2Scripting.pylog4net import Log4Net
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Net2DBXSException(Exception):
 | 
					class Net2DBXSException(Exception):
 | 
				
			||||||
@@ -5,12 +5,12 @@ import clr
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import settings
 | 
					import Net2Scripting.settings
 | 
				
			||||||
from net2xs.conversions import date_time_to_net, flex_date_time_to_net, \
 | 
					from Net2Scripting.net2xs.conversions import date_time_to_net, flex_date_time_to_net, \
 | 
				
			||||||
    time_zones_to_py, access_levels_to_py, access_level_detail_to_py
 | 
					    time_zones_to_py, access_levels_to_py, access_level_detail_to_py
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime
 | 
				
			||||||
from net2base import Net2Base
 | 
					from Net2Scripting.net2base import Net2Base
 | 
				
			||||||
from pylog4net import Log4Net
 | 
					from Net2Scripting.pylog4net import Log4Net
 | 
				
			||||||
from threading import RLock
 | 
					from threading import RLock
 | 
				
			||||||
from System import Array
 | 
					from System import Array
 | 
				
			||||||
from System.Data import DataSet
 | 
					from System.Data import DataSet
 | 
				
			||||||
@@ -53,7 +53,7 @@ try:
 | 
				
			|||||||
    # Not found: enable the packaged paxton libs
 | 
					    # Not found: enable the packaged paxton libs
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        # Add path lib path to search path
 | 
					        # Add path lib path to search path
 | 
				
			||||||
        PAXTON_LIB_DIR = os.path.join(settings.LIB_DIR, 'paxton')
 | 
					        PAXTON_LIB_DIR = os.path.join(Net2Scripting.settings.LIB_DIR, 'paxton')
 | 
				
			||||||
        if PAXTON_LIB_DIR not in sys.path:
 | 
					        if PAXTON_LIB_DIR not in sys.path:
 | 
				
			||||||
            sys.path.append(PAXTON_LIB_DIR)
 | 
					            sys.path.append(PAXTON_LIB_DIR)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										3
									
								
								Net2Scripting/network/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								Net2Scripting/network/__init__.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					"""
 | 
				
			||||||
 | 
					The module that offers several Net2 related network utilities
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
@@ -5,7 +5,7 @@ import os
 | 
				
			|||||||
import clr
 | 
					import clr
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import settings
 | 
					import Net2Scripting.settings as settings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Add path lib to search path
 | 
					# Add path lib to search path
 | 
				
			||||||
LOG4NET_LIB_DIR = os.path.join(settings.LIB_DIR, 'log4netdll')
 | 
					LOG4NET_LIB_DIR = os.path.join(settings.LIB_DIR, 'log4netdll')
 | 
				
			||||||
@@ -13,7 +13,7 @@ if LOG4NET_LIB_DIR not in sys.path:
 | 
				
			|||||||
    sys.path.append(LOG4NET_LIB_DIR)
 | 
					    sys.path.append(LOG4NET_LIB_DIR)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
clr.AddReference('log4net')
 | 
					clr.AddReference('log4net')
 | 
				
			||||||
import log4net
 | 
					import log4net as log4net
 | 
				
			||||||
from log4net.Config import XmlConfigurator
 | 
					from log4net.Config import XmlConfigurator
 | 
				
			||||||
clr.AddReference('System.Xml')
 | 
					clr.AddReference('System.Xml')
 | 
				
			||||||
from System.Xml import XmlDocument
 | 
					from System.Xml import XmlDocument
 | 
				
			||||||
							
								
								
									
										9
									
								
								Net2Scripting/settings.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Net2Scripting/settings.py
									
									
									
									
									
										Normal file
									
								
							@@ -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')
 | 
				
			||||||
							
								
								
									
										107
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										107
									
								
								README.md
									
									
									
									
									
								
							@@ -1,93 +1,54 @@
 | 
				
			|||||||
Net2Scripting
 | 
					Net2Scripting
 | 
				
			||||||
===
 | 
					===
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Python scripting for the Paxton Net2 SDK.
 | 
					Python scripting package for the Paxton Net2 SDK.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This project builds a setup file, that will install a Python scripting environment
 | 
					This project offers a Python interface to the Paxton Net2 Access Control
 | 
				
			||||||
that can communicate with Paxton Net2, using the SDK (or a direct DB connection).
 | 
					system, using the SDK or or a direct DB connection.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					It was originally a closed source project, that used py2exe to create an 
 | 
				
			||||||
 | 
					executable. V4.0 was made open source, but still used py2exe.
 | 
				
			||||||
 | 
					From V5.0 onwards it will be a Python wheel package.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Read this first
 | 
					Have a look at the samples directory (github) to get an idea how to use it.
 | 
				
			||||||
The scripts in this package are currently quite inflexible, in that they assume
 | 
					Note that it has slightly changed after becoming an installable Python package.
 | 
				
			||||||
that packages are installed in particular directories. For future versions this
 | 
					 | 
				
			||||||
should be changed to maybe an environment setting or a 'user' file containg the
 | 
					 | 
				
			||||||
definitions. (this file should be in .gitignore)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
For now, the install directories are specificly marked in the requirements.
 | 
					For the original py2exe version, pull the v4.0 tag.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Requirements
 | 
					### Requirements
 | 
				
			||||||
The NetScripting project relies on the following:
 | 
					The NetScripting project relies on the following:
 | 
				
			||||||
 * An x86 Windows environment (64-bit did not work). Windows7-32bit should be ok.
 | 
					 * A Windows environment.
 | 
				
			||||||
 * DotNet 4.0
 | 
					 * DotNet 4.0 or higher.
 | 
				
			||||||
   - Installing Paxton Net2 V5.x should take care of that
 | 
					   - Installing Paxton Net2 V5.x or higher should take care of that.
 | 
				
			||||||
   - The Paxton Net2 OEMClientLibrary dlls (v5.01) are included in this package.
 | 
					   - The Paxton Net2 OEMClientLibrary dlls (v5.01) are included in this package.
 | 
				
			||||||
 * Python x86 3.4.4
 | 
					 * pythonnet
 | 
				
			||||||
   - Is the Python environment
 | 
					   - Should be automatically installed as a dependency.
 | 
				
			||||||
   - Download from http://www.python.org
 | 
					 | 
				
			||||||
   - **Install in C:\WinPrg\Python34\ !!!**
 | 
					 | 
				
			||||||
 * pythonnet-2.3.0-cp34-cp34m-win32.whl
 | 
					 | 
				
			||||||
   - Is Python .net extension
 | 
					 | 
				
			||||||
   - Download from http://pythonnet.sourceforge.net
 | 
					 | 
				
			||||||
   - Install with pip install <wheel file>
 | 
					 | 
				
			||||||
 * py2exe-0.9.2.2-py33.py34-none-any.whl
 | 
					 | 
				
			||||||
   - To create a python executable
 | 
					 | 
				
			||||||
   - Download from http://www.py2exe.org
 | 
					 | 
				
			||||||
   - Install with pip install <wheel file>
 | 
					 | 
				
			||||||
   - Remove 'clr' in c:/WinPrg/Python34/lib/site-packages/py2exe/hooks.py !!!
 | 
					 | 
				
			||||||
   - Note that py2exe does/did not support 3.5 and up yet
 | 
					 | 
				
			||||||
 * Inno Setup 5.4.2 (higher versions most likely also work)
 | 
					 | 
				
			||||||
   - To create an installer (uses the inno_script.iss)
 | 
					 | 
				
			||||||
   - Download from http://www.jrsoftware.org   
 | 
					 | 
				
			||||||
   - **Install in C:\Program Files\Inno Setup 5\ !!!**
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The following batch files are available:
 | 
					 | 
				
			||||||
 * run.bat
 | 
					 | 
				
			||||||
   - To run de scripting tool while testing sample code
 | 
					 | 
				
			||||||
   - It will wait after execution and run again after pressing enter (ctrl C=exit)
 | 
					 | 
				
			||||||
   - Do no just click it in explorer; this will not work
 | 
					 | 
				
			||||||
   - Create a sendTo shortcut to it, to execute python scripts from the explorer. 
 | 
					 | 
				
			||||||
     + type "shell:sento" in the file explorer address bar to access the 
 | 
					 | 
				
			||||||
       SentTo folder
 | 
					 | 
				
			||||||
     + Create shortcut to run.bat and call it "Test with Net2Scripting"
 | 
					 | 
				
			||||||
 * make.bat
 | 
					 | 
				
			||||||
   - Creates an exe-based distro in ./dist
 | 
					 | 
				
			||||||
   - You can click it in explorer 
 | 
					 | 
				
			||||||
 * build_installer.bat
 | 
					 | 
				
			||||||
   - Requires make.bat to run first
 | 
					 | 
				
			||||||
   - Creates a 'SetupNet2Scripting.exe' in ./dist_installer
 | 
					 | 
				
			||||||
   - You can click it in explorer 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Beware of the following:
 | 
					 | 
				
			||||||
  * That the doc's generated, need to be defined in src/docgen.py
 | 
					 | 
				
			||||||
  * That for py2exe, new modules must be defined in 'Net2Scripting.py',
 | 
					 | 
				
			||||||
    to have py2exe include them in the exe generation.
 | 
					 | 
				
			||||||
  * That the makefile.bat will show warnings (which we ignore for now):
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
  8 missing Modules
 | 
					 | 
				
			||||||
  ------------------
 | 
					 | 
				
			||||||
? Paxton                              imported from net2xs
 | 
					 | 
				
			||||||
? _dbm                                imported from dbm.ndbm
 | 
					 | 
				
			||||||
? log4net                             imported from pylog4net
 | 
					 | 
				
			||||||
? multiprocessing.SimpleQueue         imported from concurrent.futures.process
 | 
					 | 
				
			||||||
? netbios                             imported from uuid
 | 
					 | 
				
			||||||
? win32evtlog                         imported from logging.handlers
 | 
					 | 
				
			||||||
? win32evtlogutil                     imported from logging.handlers
 | 
					 | 
				
			||||||
? win32wnet                           imported from uuid
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Configuration
 | 
					### Configuration
 | 
				
			||||||
Runtime configuration file is: src/Net2Scripting.exe.config
 | 
					To use the log4net logging, you need to call the init_logging() method before
 | 
				
			||||||
(complies to the dotnet standard)
 | 
					doing anything else. If no parameter is given, the default log setting is 
 | 
				
			||||||
 | 
					used, which sets the application log level to DEBUG, the Paxton loglevel to 
 | 
				
			||||||
 | 
					ERROR and writes to both console and a rolling log file at
 | 
				
			||||||
 | 
					${SystemDrive}/Net2 Access Control/Net2Scripting.log.
 | 
				
			||||||
 | 
					If you require non default settings, provide a path to your own config file 
 | 
				
			||||||
 | 
					as parameter. There is a sample config file in the samples directory.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Version updates
 | 
					### Building the wheel package file
 | 
				
			||||||
To update the version number, adjust the following files:
 | 
					In the directory containing setup.py run:
 | 
				
			||||||
 * inno_script.iss
 | 
					```
 | 
				
			||||||
 * src/settings.py
 | 
					python setup.py sdist bdist_wheel
 | 
				
			||||||
 * docs/README.txt
 | 
					```
 | 
				
			||||||
 | 
					The resulting wheel file should pop up in the dist directory.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Install
 | 
				
			||||||
 | 
					 * Download the whl file from the dist directory.
 | 
				
			||||||
 | 
					 * pip install Net2Scripting-X.Y.Z-py3-none-any.whl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Uninstall
 | 
				
			||||||
 | 
					 * pip uninstall Net2Scripting
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Todo
 | 
					### Todo
 | 
				
			||||||
  * Unit tests
 | 
					  * Unit tests
 | 
				
			||||||
  * Fix hard Python & InnoSetup paths
 | 
					 | 
				
			||||||
  * Add SDK features
 | 
					  * Add SDK features
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### License
 | 
					### License
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
					 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								dist/Net2Scripting-5.0.0-py3-none-any.whl
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								dist/Net2Scripting-5.0.0-py3-none-any.whl
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 1.2 KiB  | 
							
								
								
									
										121
									
								
								docs/README.txt
									
									
									
									
									
								
							
							
						
						
									
										121
									
								
								docs/README.txt
									
									
									
									
									
								
							@@ -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]
 | 
					 | 
				
			||||||
							
								
								
									
										21
									
								
								make.bat
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								make.bat
									
									
									
									
									
								
							@@ -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  | 
							
								
								
									
										6
									
								
								run.bat
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								run.bat
									
									
									
									
									
								
							@@ -1,6 +0,0 @@
 | 
				
			|||||||
@echo off
 | 
					 | 
				
			||||||
cd src
 | 
					 | 
				
			||||||
:again
 | 
					 | 
				
			||||||
c:\WinPrg\Python34\python Net2Scripting.py %1
 | 
					 | 
				
			||||||
pause
 | 
					 | 
				
			||||||
goto again
 | 
					 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										43
									
								
								samples/Net2Scripting.config
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								samples/Net2Scripting.config
									
									
									
									
									
										Normal file
									
								
							@@ -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>
 | 
				
			||||||
@@ -2,7 +2,8 @@
 | 
				
			|||||||
Sample script to add a new user
 | 
					Sample script to add a new user
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from net2xs import Net2XS
 | 
					from Net2Scripting import init_logging
 | 
				
			||||||
 | 
					from Net2Scripting.net2xs import Net2XS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Uncomment to use dotnet DateTime objects
 | 
					# Uncomment to use dotnet DateTime objects
 | 
				
			||||||
# from System import DateTime
 | 
					# from System import DateTime
 | 
				
			||||||
@@ -21,6 +22,9 @@ NET2_SERVER = "localhost"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Init log4net
 | 
				
			||||||
 | 
					    init_logging()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with Net2XS(NET2_SERVER) as net2:
 | 
					    with Net2XS(NET2_SERVER) as net2:
 | 
				
			||||||
        # Authenticate
 | 
					        # Authenticate
 | 
				
			||||||
        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
					        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
				
			||||||
@@ -3,6 +3,8 @@ Sample script to add many users with cards
 | 
				
			|||||||
"""
 | 
					"""
 | 
				
			||||||
from net2xs import Net2XS
 | 
					from net2xs import Net2XS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from Net2Scripting import init_logging
 | 
				
			||||||
 | 
					from Net2Scripting.net2xs import Net2XS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Operator id 0 is System Engineer
 | 
					# Operator id 0 is System Engineer
 | 
				
			||||||
OPERATOR_ID = 0
 | 
					OPERATOR_ID = 0
 | 
				
			||||||
@@ -14,6 +16,9 @@ NET2_SERVER = "localhost"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Init log4net
 | 
				
			||||||
 | 
					    init_logging()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with Net2XS(NET2_SERVER) as net2:
 | 
					    with Net2XS(NET2_SERVER) as net2:
 | 
				
			||||||
        # Authenticate
 | 
					        # Authenticate
 | 
				
			||||||
        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
					        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
				
			||||||
@@ -2,7 +2,8 @@
 | 
				
			|||||||
Sample script to query the database directly
 | 
					Sample script to query the database directly
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from net2dbxs import Net2DBXS
 | 
					from Net2Scripting.net2dbxs import Net2DBXS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
Sample script to detect Net2Plus modules
 | 
					Sample script to detect Net2Plus modules
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from network.net2plus import Net2PlusFinder
 | 
					from Net2Scripting.network.net2plus import Net2PlusFinder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
Sample script to detect all SQLServer instances
 | 
					Sample script to detect all SQLServer instances
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from network.sqlserver import SqlServerFinder
 | 
					from Net2Scripting.network.sqlserver import SqlServerFinder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
@@ -2,7 +2,8 @@
 | 
				
			|||||||
Sample script to fetch all access levels
 | 
					Sample script to fetch all access levels
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from net2xs import Net2XS
 | 
					from Net2Scripting import init_logging
 | 
				
			||||||
 | 
					from Net2Scripting.net2xs import Net2XS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Operator id 0 is System Engineer
 | 
					# Operator id 0 is System Engineer
 | 
				
			||||||
OPERATOR_ID = 0
 | 
					OPERATOR_ID = 0
 | 
				
			||||||
@@ -14,6 +15,9 @@ NET2_SERVER = "localhost"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Init log4net
 | 
				
			||||||
 | 
					    init_logging()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with Net2XS(NET2_SERVER) as net2:
 | 
					    with Net2XS(NET2_SERVER) as net2:
 | 
				
			||||||
        # Authenticate
 | 
					        # Authenticate
 | 
				
			||||||
        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
					        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
				
			||||||
@@ -2,7 +2,8 @@
 | 
				
			|||||||
Sample script to fetch all cards
 | 
					Sample script to fetch all cards
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from net2xs import Net2XS
 | 
					from Net2Scripting import init_logging
 | 
				
			||||||
 | 
					from Net2Scripting.net2xs import Net2XS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Operator id 0 is System Engineer
 | 
					# Operator id 0 is System Engineer
 | 
				
			||||||
OPERATOR_ID = 0
 | 
					OPERATOR_ID = 0
 | 
				
			||||||
@@ -14,6 +15,9 @@ NET2_SERVER = "localhost"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Init log4net
 | 
				
			||||||
 | 
					    init_logging()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with Net2XS(NET2_SERVER) as net2:
 | 
					    with Net2XS(NET2_SERVER) as net2:
 | 
				
			||||||
        # Authenticate
 | 
					        # Authenticate
 | 
				
			||||||
        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
					        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
				
			||||||
@@ -2,7 +2,8 @@
 | 
				
			|||||||
Sample script to fetch all time zones
 | 
					Sample script to fetch all time zones
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from net2xs import Net2XS
 | 
					from Net2Scripting import init_logging
 | 
				
			||||||
 | 
					from Net2Scripting.net2xs import Net2XS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Operator id 0 is System Engineer
 | 
					# Operator id 0 is System Engineer
 | 
				
			||||||
OPERATOR_ID = 0
 | 
					OPERATOR_ID = 0
 | 
				
			||||||
@@ -14,6 +15,9 @@ NET2_SERVER = "localhost"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Init log4net
 | 
				
			||||||
 | 
					    init_logging()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with Net2XS(NET2_SERVER) as net2:
 | 
					    with Net2XS(NET2_SERVER) as net2:
 | 
				
			||||||
        # Authenticate
 | 
					        # Authenticate
 | 
				
			||||||
        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
					        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
				
			||||||
@@ -2,7 +2,8 @@
 | 
				
			|||||||
Sample script to fetch a dataset with all active users
 | 
					Sample script to fetch a dataset with all active users
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from net2xs import Net2XS
 | 
					from Net2Scripting import init_logging
 | 
				
			||||||
 | 
					from Net2Scripting.net2xs import Net2XS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Operator id 0 is System Engineer
 | 
					# Operator id 0 is System Engineer
 | 
				
			||||||
OPERATOR_ID = 0
 | 
					OPERATOR_ID = 0
 | 
				
			||||||
@@ -14,6 +15,9 @@ NET2_SERVER = "localhost"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Init log4net
 | 
				
			||||||
 | 
					    init_logging()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with Net2XS(NET2_SERVER) as net2:
 | 
					    with Net2XS(NET2_SERVER) as net2:
 | 
				
			||||||
        # Authenticate
 | 
					        # Authenticate
 | 
				
			||||||
        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
					        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
				
			||||||
@@ -2,7 +2,8 @@
 | 
				
			|||||||
Sample script to demonstrate inheritance
 | 
					Sample script to demonstrate inheritance
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from net2xs import Net2XS
 | 
					from Net2Scripting import init_logging
 | 
				
			||||||
 | 
					from Net2Scripting.net2xs import Net2XS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Operator id 0 is System Engineer
 | 
					# Operator id 0 is System Engineer
 | 
				
			||||||
OPERATOR_ID = 0
 | 
					OPERATOR_ID = 0
 | 
				
			||||||
@@ -38,6 +39,9 @@ class MyNet2XS(Net2XS):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Init log4net
 | 
				
			||||||
 | 
					    init_logging()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with MyNet2XS(NET2_SERVER) as net2:
 | 
					    with MyNet2XS(NET2_SERVER) as net2:
 | 
				
			||||||
        # Authenticate
 | 
					        # Authenticate
 | 
				
			||||||
        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
					        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
				
			||||||
@@ -3,9 +3,9 @@ Sample script to modify a user.
 | 
				
			|||||||
It assumes that a John Doe user exists (see add_user sample).
 | 
					It assumes that a John Doe user exists (see add_user sample).
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from net2xs import Net2XS
 | 
					 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime
 | 
				
			||||||
 | 
					from Net2Scripting import init_logging
 | 
				
			||||||
 | 
					from Net2Scripting.net2xs import Net2XS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Operator id 0 is System Engineer
 | 
					# Operator id 0 is System Engineer
 | 
				
			||||||
OPERATOR_ID = 0
 | 
					OPERATOR_ID = 0
 | 
				
			||||||
@@ -22,6 +22,9 @@ SUR_NAME = "Doe"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Init log4net
 | 
				
			||||||
 | 
					    init_logging()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with Net2XS(NET2_SERVER) as net2:
 | 
					    with Net2XS(NET2_SERVER) as net2:
 | 
				
			||||||
        # Authenticate
 | 
					        # Authenticate
 | 
				
			||||||
        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
					        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
				
			||||||
@@ -2,9 +2,9 @@
 | 
				
			|||||||
Sample script to monitor acu
 | 
					Sample script to monitor acu
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from Net2Scripting import init_logging
 | 
				
			||||||
 | 
					from Net2Scripting.net2xs import Net2XS
 | 
				
			||||||
from time import sleep
 | 
					from time import sleep
 | 
				
			||||||
from net2xs import Net2XS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Operator id 0 is System Engineer
 | 
					# Operator id 0 is System Engineer
 | 
				
			||||||
OPERATOR_ID = 0
 | 
					OPERATOR_ID = 0
 | 
				
			||||||
@@ -28,6 +28,9 @@ def handle_acu_event(sender, event_view):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Init log4net
 | 
				
			||||||
 | 
					    init_logging()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with Net2XS(NET2_SERVER) as net2:
 | 
					    with Net2XS(NET2_SERVER) as net2:
 | 
				
			||||||
        # Authenticate
 | 
					        # Authenticate
 | 
				
			||||||
        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
					        net2.authenticate(OPERATOR_ID, OPERATOR_PWD)
 | 
				
			||||||
@@ -3,9 +3,9 @@ Sample script to hold all known doors open for a few seconds.
 | 
				
			|||||||
Also shows how to use the logger function.
 | 
					Also shows how to use the logger function.
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
 | 
					from Net2Scripting import init_logging
 | 
				
			||||||
from net2xs import Net2XS
 | 
					from Net2Scripting.net2xs import Net2XS
 | 
				
			||||||
from pylog4net import Log4Net
 | 
					from Net2Scripting.pylog4net import Log4Net
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Operator id 0 is System Engineer
 | 
					# Operator id 0 is System Engineer
 | 
				
			||||||
OPERATOR_ID = 0
 | 
					OPERATOR_ID = 0
 | 
				
			||||||
@@ -28,6 +28,9 @@ def get_doors(net2):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if __name__ == "__main__":
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Init log4net
 | 
				
			||||||
 | 
					    init_logging()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Create logger object
 | 
					    # Create logger object
 | 
				
			||||||
    logger = Log4Net.get_logger('open_all_doors')
 | 
					    logger = Log4Net.get_logger('open_all_doors')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										30
									
								
								setup.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								setup.py
									
									
									
									
									
										Normal file
									
								
							@@ -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'
 | 
					 | 
				
			||||||
							
								
								
									
										35
									
								
								src/setup.py
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								src/setup.py
									
									
									
									
									
								
							@@ -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'
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user