Skip to content

Commit 03e5c4a

Browse files
committed
first commit
0 parents  commit 03e5c4a

16 files changed

+3203
-0
lines changed

.gitignore

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
98+
__pypackages__/
99+
100+
# Celery stuff
101+
celerybeat-schedule
102+
celerybeat.pid
103+
104+
# SageMath parsed files
105+
*.sage.py
106+
107+
# Environments
108+
.env
109+
.venv
110+
env/
111+
venv/
112+
ENV/
113+
env.bak/
114+
venv.bak/
115+
116+
# Spyder project settings
117+
.spyderproject
118+
.spyproject
119+
120+
# Rope project settings
121+
.ropeproject
122+
123+
# mkdocs documentation
124+
/site
125+
126+
# mypy
127+
.mypy_cache/
128+
.dmypy.json
129+
dmypy.json
130+
131+
# Pyre type checker
132+
.pyre/
133+
134+
# pytype static type analyzer
135+
.pytype/
136+
137+
# Cython debug symbols
138+
cython_debug/
139+
/.vs
140+
Python/temp/*
141+
Python/config.ini

CheckMessages.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import time,jmfmessages
2+
nroftest = 30
3+
nrofthreads = 30
4+
5+
def loopqueue ():
6+
for x in range(nroftest):
7+
start_time = time.time()
8+
nrentries=len(jmfmessages.ReturnQueueEntries(printer," "))
9+
timeused=time.time()-start_time
10+
print("Time:",start_time,"ReturnQueueEntries:",nrentries,"Pass:",x+1,"Time:",timeused)
11+
def sendjob ():
12+
for x in range(nroftest):
13+
start_time = time.time()
14+
nrentries=jmfmessages.SendJob(printer)
15+
timeused=time.time()-start_time
16+
print("Time:",start_time,"SendJob:",nrentries,"Pass:",x+1, timeused)
17+
18+
printer="http://fat-cep-601.ocevenlo.oce.net:8010"
19+
20+
# print("SendJob:",jmfmessages.SendJob(printer,1,1))
21+
# print("ReturnQueueEntries",len(jmfmessages.ReturnQueueEntries(printer," ")))
22+
23+
from threading import Thread
24+
25+
if __name__ == '__main__':
26+
list_threads = []
27+
for tnr in range (0,nrofthreads):
28+
t1 = Thread(target = sendjob)
29+
t2 = Thread(target = loopqueue)
30+
list_threads.append(t1)
31+
list_threads.append(t2)
32+
for t in list_threads:
33+
t.start()
34+
for t in list_threads:
35+
t.join()
36+
37+
print("Removed:",jmfmessages.RemoveQueueEntries(printer, " "))

CreateMimePackage.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import requests
2+
import xml.dom.minidom
3+
import time
4+
from jmfmessages import CreateMimePackage
5+
6+
# The jmfmessages library contains examples of how jmf can be used to send commands to PRISMAsync and obtain information from PRISMAsync
7+
# This file is an example of how the libraries can be used to create a full mime package (including PDF)
8+
9+
print("Mime-package created with filename:",CreateMimePackage("jmfjdf/SubmitQueueEntry.jmf","jmfjdf/job1.jdf", "file://jmfjdf/Test.pdf"))

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Python Examples
2+
## Introduction
3+
These examples are created using Python3. Python is available for a lot of platforms including Windows. A version of Python can be downloaded here: https://www.python.org/downloads/
4+
Note that these examples have been created using Python3
5+
6+
## Installation
7+
Run the downloaded Python installer and make sure to check "Add Python 3.x to PATH"
8+
9+
## Configuration
10+
Some Python libraries need to be installed before you can use these examples. To install the needed linraries, run:
11+
12+
```python -m pip install -r requirements.txt```
13+
14+
When behind a proxy use:
15+
16+
```python -m pip install -r requirements.txt --proxy http://proxy.oce.net:81```
17+
18+
## Check installation
19+
If everything is working properly, you should be able to run the following command:
20+
21+
```python CreateMimePackage.py```

SendJob.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import requests
2+
import xml.dom.minidom
3+
import time
4+
from jmfmessages import SendJob
5+
6+
# The jmfmessages library contains examples of how jmf can be used to send commands to PRISMAsync and obtain information from PRISMAsync
7+
# This file is an example of how the libraries can be used to send jobs to PRISMAsync
8+
9+
print("Job was submitted and has QueueEntryID:",SendJob("http://hq-cep3.oce.nl:8010", "file://jmfjdf/Test.pdf"))
10+
print("Job was submitted and has QueueEntryID:",SendJob("http://hq-cep3.oce.nl:8010", "http://ubuntu-hdok.ocevenlo.oce.net/pdf/PosterFashionWomanplusTextSample.pdf"))

config.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Printer]
2+
;Provide the URL to the printer in the form: http://printer-ip:jmf_port
3+
PRISMAsyncUrl = "http://fat-cep-601.ocevenlo.oce.net:8010"
4+
5+
[Jobs]
6+
StatusToRemove = Completed
7+
SendPdfAsMime = Yes
8+
UrlforPDF = http://ubuntu-hdok.ocevenlo.oce.net/pdf/PosterFashionWomanplusTextSample.pdf
9+
RemoveMime = Yes

config.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import configparser
2+
import argparse
3+
4+
config = configparser.ConfigParser(allow_no_value=True)
5+
config.optionxform=str
6+
config_file='config.ini'
7+
8+
try:
9+
config.read('config.ini')
10+
printer = config['Printer']
11+
jobs = config['Jobs']
12+
except:
13+
print("Config file not read, creating a new one")
14+
if not config.has_section('Printer'):
15+
config.add_section('Printer')
16+
config.set('Printer', ';Provide the URL to the printer in the form: http://printer-ip:jmf_port')
17+
config.set('Printer', 'PRISMAsyncUrl', "http://PRISMAsync.network.lan:8010")
18+
if not config.has_section('Jobs'):
19+
config.add_section('Jobs')
20+
config.set('Jobs', 'StatusToRemove', "Completed")
21+
config.set('Jobs', ';Provide URL for PDF starting with either http:// or file.')
22+
config.set('Jobs', ';If a file url is provided the PDF will be send as part of a mime package')
23+
config.set('Jobs', 'UrlforPDF', "http://ubuntu-hdok.ocevenlo.oce.net/pdf/PosterFashionWomanplusTextSample.pdf")
24+
config.set('Jobs','RemoveMime', "Yes")
25+
with open('config.ini', 'w') as fp:
26+
config.write(fp)
27+
print("Please adapt",config_file, "to your situation")
28+
exit(0)
29+
30+
# The following block is used to take command line options for this tool.
31+
# It needs a printer address and an opional --status. --help is automatically generated
32+
parser = argparse.ArgumentParser(description='Delete all JMF QueueEntries that have the provided status from PRISMAsync')
33+
parser.add_argument('--url', type=str, default=printer['PRISMAsyncUrl'],
34+
help='full url to PRISMAsync jmf interface. (default: '+printer['PRISMAsyncUrl']+')')
35+
parser.add_argument('--status', '-s', type=str, default=jobs['StatusToRemove'],
36+
help='The status of the jobs that need to be removed (default:'+jobs['StatusToRemove']+')')
37+
parser.add_argument('--pdf', '-p', type=str, default=jobs['UrlforPDF'],
38+
help='Provide URL for PDF starting with either http:// or file. (default:'+jobs['UrlforPDF']+')')
39+
parser.add_argument('--removemime', '-k', type=str, default=jobs['RemoveMime'], choices=['Yes', 'No'],
40+
help='Remove mime package after sendig (default:'+jobs['RemoveMime']+')')
41+
args = parser.parse_args()
42+
43+
44+
url=args.url
45+
status=args.status
46+
pdf=args.pdf
47+
removemime=(args.removemime == 'Yes')

deleteQueueEntries.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import jmfmessages
2+
import config
3+
print(jmfmessages.RemoveQueueEntries(config.url, config.status), "QueueEntries have been removed")

jmfjdf/QueueStatus.jmf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<JMF xmlns="http://www.CIP4.org/JDFSchema_1_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MaxVersion="1.5" SenderID="Python by hdok" TimeStamp="2020-08-30T11:39:00+02:00" Version="1.5" xsi:type="JMFRootMessage">
3+
<Query ID="Completed-12345" Type="QueueStatus" xsi:type="QueryQueueStatus">
4+
<QueueFilter StatusList="STATUS"/>
5+
</Query>
6+
</JMF>

jmfjdf/RemoveQueueEntry.jmf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<JMF xmlns="http://www.CIP4.org/JDFSchema_1_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SenderID="Python by hdok" TimeStamp="2020-08-30T16:12:32+02:00" Version="1.3">
3+
<Command ID="PYTHON_IZAEIP_195_20190830161232" Type="RemoveQueueEntry" xsi:type="CommandRemoveQueueEntry">
4+
<QueueEntryDef QueueEntryID="QUEUEENTRY" />
5+
</Command>
6+
</JMF>

0 commit comments

Comments
 (0)