Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
669fe5b3
Commit
669fe5b3
authored
May 05, 2013
by
D1plo1d
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing change_job so that setting the position changes the print job's position in the queue.
parent
a1123637
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
pronserve.py
pronserve.py
+13
-13
No files found.
pronserve.py
View file @
669fe5b3
...
@@ -329,6 +329,8 @@ class Pronserve(pronsole.pronsole, EventEmitter):
...
@@ -329,6 +329,8 @@ class Pronserve(pronsole.pronsole, EventEmitter):
self
.
jobs
.
remove
(
int
(
job_id
))
self
.
jobs
.
remove
(
int
(
job_id
))
def
do_change_job
(
self
,
job_id
,
**
kwargs
):
def
do_change_job
(
self
,
job_id
,
**
kwargs
):
print
job_id
print
kwargs
self
.
jobs
.
update
(
int
(
job_id
),
kwargs
)
self
.
jobs
.
update
(
int
(
job_id
),
kwargs
)
def
do_get_jobs
(
self
):
def
do_get_jobs
(
self
):
...
@@ -345,7 +347,7 @@ class Pronserve(pronsole.pronsole, EventEmitter):
...
@@ -345,7 +347,7 @@ class Pronserve(pronsole.pronsole, EventEmitter):
self
.
fire
(
"job_finished"
,
self
.
jobs
.
sanitize
(
self
.
current_job
))
self
.
fire
(
"job_finished"
,
self
.
jobs
.
sanitize
(
self
.
current_job
))
if
len
(
self
.
jobs
.
list
)
>
0
:
if
len
(
self
.
jobs
.
list
)
>
0
:
print
"Starting the next print job"
print
"Starting the next print job"
self
.
current_job
=
self
.
jobs
.
list
.
pop
left
(
)
self
.
current_job
=
self
.
jobs
.
list
.
pop
(
0
)
self
.
p
.
startprint
(
self
.
current_job
[
'body'
]
.
split
(
"
\n
"
))
self
.
p
.
startprint
(
self
.
current_job
[
'body'
]
.
split
(
"
\n
"
))
self
.
fire
(
"job_started"
,
self
.
jobs
.
sanitize
(
self
.
current_job
))
self
.
fire
(
"job_started"
,
self
.
jobs
.
sanitize
(
self
.
current_job
))
else
:
else
:
...
@@ -361,7 +363,6 @@ class Pronserve(pronsole.pronsole, EventEmitter):
...
@@ -361,7 +363,6 @@ class Pronserve(pronsole.pronsole, EventEmitter):
gen
.
Task
(
self
.
ioloop
.
add_timeout
(
next_timeout
,
self
.
run_print_queue_loop
))
gen
.
Task
(
self
.
ioloop
.
add_timeout
(
next_timeout
,
self
.
run_print_queue_loop
))
def
update_job_progress
(
self
,
progress
):
def
update_job_progress
(
self
,
progress
):
print
progress
if
progress
!=
self
.
previous_job_progress
and
self
.
current_job
!=
None
:
if
progress
!=
self
.
previous_job_progress
and
self
.
current_job
!=
None
:
self
.
previous_job_progress
=
progress
self
.
previous_job_progress
=
progress
self
.
fire
(
"job_progress_changed"
,
progress
)
self
.
fire
(
"job_progress_changed"
,
progress
)
...
@@ -428,7 +429,7 @@ class PrintJobQueue(EventEmitter):
...
@@ -428,7 +429,7 @@ class PrintJobQueue(EventEmitter):
def
__init__
(
self
):
def
__init__
(
self
):
super
(
PrintJobQueue
,
self
)
.
__init__
()
super
(
PrintJobQueue
,
self
)
.
__init__
()
self
.
list
=
deque
([])
self
.
list
=
[]
self
.
__last_id
=
0
self
.
__last_id
=
0
def
public_list
(
self
):
def
public_list
(
self
):
...
@@ -441,19 +442,13 @@ class PrintJobQueue(EventEmitter):
...
@@ -441,19 +442,13 @@ class PrintJobQueue(EventEmitter):
def
sanitize
(
self
,
job
):
def
sanitize
(
self
,
job
):
return
dict
(
return
dict
(
id
=
job
[
"id"
],
id
=
job
[
"id"
],
original_file_name
=
job
[
"original_file_name"
],
file_name
=
job
[
"original_file_name"
],
rank
=
job
[
"rank"
]
)
)
def
order
(
self
):
sorted
(
self
.
list
,
key
=
lambda
job
:
job
[
'rank'
])
def
add
(
self
,
original_file_name
,
body
):
def
add
(
self
,
original_file_name
,
body
):
ext
=
os
.
path
.
splitext
(
original_file_name
)[
1
]
ext
=
os
.
path
.
splitext
(
original_file_name
)[
1
]
job
=
dict
(
job
=
dict
(
id
=
self
.
__last_id
,
id
=
self
.
__last_id
,
rank
=
len
(
self
.
list
),
original_file_name
=
original_file_name
,
original_file_name
=
original_file_name
,
body
=
body
,
body
=
body
,
)
)
...
@@ -482,9 +477,14 @@ class PrintJobQueue(EventEmitter):
...
@@ -482,9 +477,14 @@ class PrintJobQueue(EventEmitter):
job
=
self
.
find_by_id
(
job_id
)
job
=
self
.
find_by_id
(
job_id
)
if
job
==
None
:
if
job
==
None
:
return
False
return
False
job
[
'rank'
]
=
job_attrs
[
'position'
]
# proposed future print quantity functionality
self
.
order
()
# if hasattr(job_attrs, 'qty'): job['qty'] = qty
print
"Print Job Updated"
if
job_attrs
[
'position'
]:
position
=
int
(
job_attrs
[
'position'
])
self
.
list
.
remove
(
job
)
self
.
list
.
insert
(
position
,
job
)
print
int
(
job_attrs
[
'position'
])
print
"Print #
%
s Job Updated (
%
s )."
%
(
job
[
'id'
],
job
[
'original_file_name'
])
self
.
fire
(
"job_updated"
,
job
)
self
.
fire
(
"job_updated"
,
job
)
def
find_by_id
(
self
,
job_id
):
def
find_by_id
(
self
,
job_id
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment