These are chat archives for PaperCutSoftware/PaperCutExamples

15th
Aug 2017
Alec Clews
@alecthegeek
Aug 15 2017 04:04
And you got a credit for the Perl script you provided :-)
Jonathan Bennetts
@Joffcom
Aug 15 2017 05:11
You did a better job with it, I was happy for my first ever attempt at Perl though
Alec Clews
@alecthegeek
Aug 15 2017 05:31
Jonathan Bennetts
@Joffcom
Aug 15 2017 05:32
It looks like it will be worth a read, Thanks for the link to the print scripts as well :smiley:
I have used the blog posts that go with them as reference points for people in the past as well
Alec Clews
@alecthegeek
Aug 15 2017 05:34
:+1:
Alec Clews
@alecthegeek
Aug 15 2017 07:19
I've just discovered how to use the getTaskStatus()method
#!/usr/bin/env python3

# Load a lot of data and use getTaskStatus()

import xmlrpc.client
import sys

host="http://localhost:9191/rpc/api/xmlrpc" # If not localhost then this address will need to be whitelisted in PaperCut

auth="password"  # Value defined in advanced config property "auth.webservices.auth-token". Should be random


# Generate a file of dataA

fileName = "/tmp/import.file"

f = open(fileName, 'w')

for p in range(20):
    f.write("parentAccount{}\t\t\t\t\t\t\t\t\t\t\n".format(p))
    for a in range(100):
        f.write("{}LongParentAccountname\t{}ReallyLongSharedAccountName\t\t{}x{}\t10\t\t\t[All Users]\t\t\t\n".format(p, a, p, a))

f.close()

proxy = xmlrpc.client.ServerProxy(host)

proxy.api.batchImportSharedAccounts(auth, fileName, False, False)

status = proxy.api.getTaskStatus()
while not status["completed"]:
    print("{}\n".format(status))
    status = proxy.api.getTaskStatus()

print("{}\n".format(proxy.api.getTaskStatus()))
Jonathan Bennetts
@Joffcom
Aug 15 2017 07:21
Does it just return the status of the last task?
or does it only work with batch?
Alec Clews
@alecthegeek
Aug 15 2017 07:23
It works with the import methods, performGroupSync, processJob (I assume) and probably a few others.
Jonathan Bennetts
@Joffcom
Aug 15 2017 07:23
That could be handy
Alec Clews
@alecthegeek
Aug 15 2017 07:24
Accept the docs gave no clue on how to use it. I'm also not sure what happens if you start multple jobs :grinning:
Jonathan Bennetts
@Joffcom
Aug 15 2017 07:25
A good example might be to use that along with exportUserDataHistory
Alec Clews
@alecthegeek
Aug 15 2017 07:25
yup
Jonathan Bennetts
@Joffcom
Aug 15 2017 07:28
Actually I have an idea for the exportUserDataHistory method as well, If I get a few minutes today I will put something together
I am thinking about adding a link to /User for "Export Data" that can go to papercut:xxx/export/username and it will run the call and email the output to the user
Alec Clews
@alecthegeek
Aug 15 2017 07:31
very clever
Jonathan Bennetts
@Joffcom
Aug 15 2017 07:32
I need to have a proper look at the API calls but the theory is solid, Can use a small Go HTTP service to do all the work
Alec Clews
@alecthegeek
Aug 15 2017 07:56
Would work no problem