Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Mycroft Holmes
Mar 26, 2010

by Azathoth
yeah, I'm going to the ILC tomorrow for more help. Thanks for your help, though!

Adbot
ADBOT LOVES YOU

Wallet
Jun 19, 2006

The Fool posted:

I believe he was counting just 'E' or just 'e', and I assume he needed the count of both.

Entirely possible.

Fluue
Jan 2, 2008
Something that I haven't found a good answer to:

When trying to write simpler functions to encapsulate logic/business rules that require calling out to 3rd party web APIs, should I use the module-as-singleton pattern when dealing with the API client? Instead of having some kind of controller class with the API client injected, I would use something like:

code:
# external_api.py

class AnExternalAPI:
    pass

client = AnExternalAPI()
code:
# actions.py
from external_api import client

def add_ticket_approvers(ticket: Ticket, approvers: list):
    ... 
    client.update_ticket(ticket, approvers)
    ...
The API client also uses a stored token for authentication, so it needs to initialize with that as a parameter before the client is usable.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Ehh, kind of depends on what your client does.

It it's inexpensive, I'd just initialize it wherever you need to use it.

If it needs to track state for like throttling or something, then I'd do it like you say.

mr_package
Jun 13, 2000
Check out 'high contrast' theme in PyCharm. Ugly at first but now I love the 100% flatness of it.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

mr_package posted:

Check out 'high contrast' theme in PyCharm. Ugly at first but now I love the 100% flatness of it.

I used it for awhile. It remained ugly, but I agree about the appealingness of the flat look.

I'm using Material UI nowadays.

unpacked robinhood
Feb 18, 2013

by Fluffdaddy
I have a project ProjectA that needs moduleFoo.
ModuleFoo provides a setup.py and was installed in a conda env, it can be imported in the env's interpreter.
However ProjectA doesn't work unless I also add the absolute path to moduleFoo in PYTHONPATH, which I currently do in a bash script.

I'd like to know how to deal with this cleanly.
Should I have ProjectA's setup.py create the bash file with the correct paths ? (Assuming both directories sit next to each other)

It doesn't look clean to rely on both a local and installed version of the module.

unpacked robinhood fucked around with this message at 12:01 on Jun 28, 2019

SurgicalOntologist
Jun 17, 2004

You almost certainly can solve this without ever dealing with paths. But it's not quite clear what the problem is. To me, this:

unpacked robinhood posted:

ModuleFoo provides a setup.py and was installed in a conda env, it can be imported in the env's interpreter.
and this:

unpacked robinhood posted:

However ProjectA doesn't work unless I also add the absolute path to moduleFoo in PYTHONPATH, which I currently do in a bash script.
don't make sense together. If you can import moduleFoo successfully, why do you need to add its path?

unpacked robinhood
Feb 18, 2013

by Fluffdaddy

SurgicalOntologist posted:

You almost certainly can solve this without ever dealing with paths. But it's not quite clear what the problem is. To me, this:

and this:

don't make sense together. If you can import moduleFoo successfully, why do you need to add its path?

Î don't understand it either. Is it possible ModuleFoo isn't installed correctly, as in "import ModuleFoo" goes fine, but actually using it from ProjectA doesn't work because it's accessing missing parts ?

e: Fixed. Probably a botched module install due to space issues on my vm.

unpacked robinhood fucked around with this message at 14:17 on Jun 28, 2019

General_Failure
Apr 17, 2005
I'm just going around and around in circles. Is there a way to set Jupyter notebook / lab to accept a local IP address range? Ie 192.168.1.0/24
Really I just want to be able to use my Jetson Nano headless. I mean I can with ssh and rdp, but Jupyter would be a great platform to utilise it with, but the documentation is so drat terrible and I can't work out how to allow connections from only my LAN.
It'd only be me connecting to it so it doesn't need to be anything fancy like Jupyter Hub. It just seems kind of silly to me that a browser based IDE thing is such a drat pain to use from other computers.

SurgicalOntologist
Jun 17, 2004

The easiest way is to use the argument --ip='0.0.0.0'. This will allow any connection, but assuming your Jetson isn't exposed to the WAN it won't matter. If it is exposed, then I'm not sure what to put exactly but maybe the local LAN IP of the Nano.

nonathlon
Jul 9, 2004
And yet, somehow, now it's my fault ...
I used to use ZopeSkel to generate package boilerplate. That seems to have been replaced by templer. And templer has been replaced by what?

Because templer.core is not installing on my system and it was last updated 6 years. So there must be a Brand New Thing.

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

General_Failure posted:

I'm just going around and around in circles. Is there a way to set Jupyter notebook / lab to accept a local IP address range? Ie 192.168.1.0/24
Really I just want to be able to use my Jetson Nano headless. I mean I can with ssh and rdp, but Jupyter would be a great platform to utilise it with, but the documentation is so drat terrible and I can't work out how to allow connections from only my LAN.
It'd only be me connecting to it so it doesn't need to be anything fancy like Jupyter Hub. It just seems kind of silly to me that a browser based IDE thing is such a drat pain to use from other computers.

You could also give it a static IP if it's just at home. But really just do `0.0.0.0`, that's no less safe than the local ips unless it has a direct line out to the world. If you're really worried put nginx in front of it.

i vomit kittens
Apr 25, 2019


So I'm making my first program with a non-HTML GUI using PyQt and I'm running into an issue with a Table widget not updating properly. It's a simple tool I'm working on for a student organization I'm in that keeps track of their soon-to-be-implemented points system for attending events. I have this method, update_student that is supposed to go through the table and update everything that changes for the necessary people:

code:
    def update_student(self, sdt, ev):
        print("Updating " + sdt.name)
        y = self.student_table.rowCount()
        for row in range(0, y):
            if sdt.name == self.student_table.item(row, 0).text():
                self.student_table.setItem(row, 1, QTableWidgetItem(str(sdt.bar)))

                if ev.category == "cat1":
                    if sdt.ind_req == 1:
                        self.student_table.setItem(row, 2, QTableWidgetItem("Complete"))
                    else:
                        self.student_table.setItem(row, 2, QTableWidgetItem("Incomplete"))

                elif ev.category == "cat2":
                    if sdt.sob_req == 1:
                        self.student_table.setItem(row, 3, QTableWidgetItem("Complete"))
                    else:
                        self.student_table.setItem(row, 3, QTableWidgetItem("Incomplete"))

                elif ev.category == "cat3":
                    if sdt.fel_req == 1:
                        self.student_table.setItem(row, 4, QTableWidgetItem("Complete"))
                    else:
                        self.student_table.setItem(row, 4, QTableWidgetItem("Incomplete"))

                elif ev.category == "cat4":
                    if sdt.high_req == 1:
                        self.student_table.setItem(row, 5, QTableWidgetItem("Complete"))
                    else:
                        self.student_table.setItem(row, 5, QTableWidgetItem("Incomplete"))

                elif ev.category == "cat5":
                    if sdt.misc_req == 1:
                        self.student_table.setItem(row, 6, QTableWidgetItem("Complete"))
                    else:
                        self.student_table.setItem(row, 6, QTableWidgetItem("Incomplete"))

                elif ev.category == "cat6":
                    if sdt.ass_req == 1:
                        self.student_table.setItem(row, 7, QTableWidgetItem("Complete"))
                    else:
                        self.student_table.setItem(row, 7, QTableWidgetItem("Incomplete"))
                else:
                    print("No category.")
This method can be called by two different actions: The attendance for an event being taken, which is done in a separate window, or a button on the same window as the table that toggles the point penalty on or off for not hitting any of these requirements. Whenever it is called after attendance is taken, the table updates instantly. However, pressing the button to toggle the penalties only updates the table after I minimize the window it's in and bring it back up (the values for the student object are still updated instantly, however). I'm not really sure why this is happening at the moment, so if anyone can point out why this might be I'd appreciate it.

The attendance method that calls update_student from a different window is:

code:
    def button_clicked(self, check_boxes):
        is_attended = False

        for box in check_boxes:
            sdt = self.db.get_student(box.text())

            if box.isChecked():
                is_attended = True
                if self.ev.name in sdt.events_attended:
                    print("Already given credit.")
                else:
                    sdt.bar += int(self.ev.bar)
                    sdt.events_attended.append(self.ev.name)
                    self.db.update_att(sdt)

                    if self.ev.category is not "Body Meeting":
                        self.db.update_req(self.ev.category, sdt)
                        self.app_window.update_student(sdt, self.ev.category)

            else:
                if self.ev.name in sdt.events_attended:
                    sdt.bar -= int(self.ev.bar)
                    sdt.events_attended.remove(self.ev.name)
                    self.db.update_att(sdt)
                    self.db.update_req(self.ev.category, sdt)
                    self.app_window.update_student(sdt, self.ev.category)

        self.db.set_ev_attended(self.ev, is_attended)
        self.app_window.update_event(self.ev, is_attended)
And the button in the table's window that calls it:

code:
    def toggle_penalty_clicked(self, penalty_label):
        self.pen_fl.toggle_status()
        self.db.update_flag(self.pen_fl)

        if self.pen_fl.status == 1:
            penalty_label.setText("Penalties are ON.")
            for sdt in self.db.get_all_students():
                sdt.apply_penalty()
                self.db.update_pen(sdt)
                self.update_student(sdt, "none")
        else:
            penalty_label.setText("Penalties are OFF.")
            for sdt in self.db.get_all_students():
                sdt.remove_penalty()
                self.db.update_pen(sdt)
                self.update_student(sdt, "none")
Note that the penalty_label text does update instantly even though the table does not.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

nonathlon posted:

I used to use ZopeSkel to generate package boilerplate. That seems to have been replaced by templer. And templer has been replaced by what?

Because templer.core is not installing on my system and it was last updated 6 years. So there must be a Brand New Thing.

Wow zope and plone are some blasts from the past!

As I haven't used either in many years, I can't answer your question exactly other than to say that those aren't exactly cutting edge. There's not a lot of new places deploying zope/plone so there's likely not a ton of developments for spinning up new projects.

General_Failure
Apr 17, 2005

Phobeste posted:

that's no less safe than the local ips unless it has a direct line out to the world.

... You are right. This is why I ask questions. I've been hung up on it for ages completely blind to the obvious. Thanks! Yeah it's just a bog standard LAN behind an ADSL2+ router.

General_Failure fucked around with this message at 06:42 on Jul 2, 2019

nonathlon
Jul 9, 2004
And yet, somehow, now it's my fault ...

Thermopyle posted:

Wow zope and plone are some blasts from the past!

As I haven't used either in many years, I can't answer your question exactly other than to say that those aren't exactly cutting edge. There's not a lot of new places deploying zope/plone so there's likely not a ton of developments for spinning up new projects.

I know, blast from the past.

ZopeSkel was one of the few tools to escape the Zope/Plone blackhole and actually be widely useful - it used paster / pythonpaste to make a commandline tool that could be used for generating the boilerplate for a package, a namespace package with all the necessary metadata files and config set up for distribution. I found it really useful.

It looks like it was replaced by templer (now dead) and the current options are cookiecutter, create-python-package. modern-package-template and a whole lot of v.0.0.1 tools with no documentation.

(As an aside, looking for ZopeSkel lead me to look at the Zope community for the first time in years. There's an interesting social study there, a once popular tool and community that choked on its own technology and is now staggering around like a zombie.)

Dominoes
Sep 20, 2007

I made A package for dimensional analysis in SI units. Looking for suggestions/critique.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

nonathlon posted:

I know, blast from the past.

ZopeSkel was one of the few tools to escape the Zope/Plone blackhole and actually be widely useful - it used paster / pythonpaste to make a commandline tool that could be used for generating the boilerplate for a package, a namespace package with all the necessary metadata files and config set up for distribution. I found it really useful.

It looks like it was replaced by templer (now dead) and the current options are cookiecutter, create-python-package. modern-package-template and a whole lot of v.0.0.1 tools with no documentation.

(As an aside, looking for ZopeSkel lead me to look at the Zope community for the first time in years. There's an interesting social study there, a once popular tool and community that choked on its own technology and is now staggering around like a zombie.)

Oh, see I didn't even realize you could use ZopeSkel for non-Zope stuff.

AFAIK, there's nothing that's really great at this. Mainly because python distribution/packaging is still a garbage fire. I think you mentioned the main options.

There's been a lot of talk in the community about the situation recently, so maybe something will improve.

On a vaguely related note, I came across PyOxidizer today. It seems like it might be a neat solution to the distribute-a-python-application-as-a-single-executable problem.

It embeds the python interpreter into a Rust executable and wires it all up so your code Just Works.

Dominoes
Sep 20, 2007

Thermopyle posted:

On a vaguely related note, I came across PyOxidizer today. It seems like it might be a neat solution to the distribute-a-python-application-as-a-single-executable problem.

It embeds the python interpreter into a Rust executable and wires it all up so your code Just Works.
Can't find a non-trivial use in the guide, and there are no examples.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dominoes posted:

Can't find a non-trivial use in the guide, and there are no examples.

Well it was released only last week.

File an issue.

Dominoes
Sep 20, 2007

Thermopyle posted:

File an issue.
Already is one

mr_package
Jun 13, 2000
I did some data modeling using @dataclass objects but I'm suddenly very very confused by the implementation for @property and @x.setter. Is this comment anything to really be concerned about :
https://stackoverflow.com/questions/51079503/python-dataclass-and-property-decorator#comment91326305_51080197

I did also read https://blog.florimond.dev/reconciling-dataclasses-and-properties-in-python and no way am I doing this.

I'm confused because I just watched a bunch of stuff re: @dataclasses and didn't even see this come up in the discussion but I may have to re-watch now that I know what I'm looking for. Is it even a problem? Do we live with it? Or do we back away and say "Python is built on dictionaries I'm just going to use a dictionary instead"?

QuarkJets
Sep 8, 2008

mr_package posted:

I did some data modeling using @dataclass objects but I'm suddenly very very confused by the implementation for @property and @x.setter. Is this comment anything to really be concerned about :
https://stackoverflow.com/questions/51079503/python-dataclass-and-property-decorator#comment91326305_51080197

I did also read https://blog.florimond.dev/reconciling-dataclasses-and-properties-in-python and no way am I doing this.

I'm confused because I just watched a bunch of stuff re: @dataclasses and didn't even see this come up in the discussion but I may have to re-watch now that I know what I'm looking for. Is it even a problem? Do we live with it? Or do we back away and say "Python is built on dictionaries I'm just going to use a dictionary instead"?

If you use @dataclass, or classes at all, you're also kind of using dictionaries anyway so it's all gravy :shrug:

The fix is in that blog post (labeled Attempt 5), and I don't think "no way am I doing this" makes sense to say because fixing the issue only requires 1 additional line per @property. Specifically, you need to exclude the private attribute from __init__, which will allow the setter to get invoked when @dataclass assigns a value to the public version of the attribute. This is less intuitive than it could be (it would be nice if @dataclass could be smart enough to automagically identify that one of the attributes is a @property), but it makes sense when you understand what @dataclass and @property are doing.

CarForumPoster
Jun 26, 2013

⚡POWER⚡
TLDR: Is pywin32 the only/easiest way to print PDFs with python on windows?

——

I want to print a few hundred PDFs per week in a specific order from a specific copier and with alternating printer properties on windows. Some are hole punched with paper from tray one, some are b&w only from tray 2. Batch printing greatly slows down the manufacturing process that follows printing (assembling documents and mailers)

Pywin32 looks complicated as gently caress for what should be a trivial problem. The “shell” method looks like it wouldn’t take enough arguments leaving me reading MSDN docs and going very low level. Has there really been no progress since 2010 or so?!

Edit: I only have about 4 configs and 1 printer on 1 port I’m concerned with so I am going to try installing the same printer 4 additional times with unique names and default settings. Not an elegant pythonic solution but should work.

CarForumPoster fucked around with this message at 22:36 on Jul 6, 2019

QuarkJets
Sep 8, 2008

Have you looked at pkipplib or win32print?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

CarForumPoster posted:

TLDR: Is pywin32 the only/easiest way to print PDFs with python on windows?

——

I want to print a few hundred PDFs per week in a specific order from a specific copier and with alternating printer properties on windows. Some are hole punched with paper from tray one, some are b&w only from tray 2. Batch printing greatly slows down the manufacturing process that follows printing (assembling documents and mailers)

Pywin32 looks complicated as gently caress for what should be a trivial problem. The “shell” method looks like it wouldn’t take enough arguments leaving me reading MSDN docs and going very low level. Has there really been no progress since 2010 or so?!

Edit: I only have about 4 configs and 1 printer on 1 port I’m concerned with so I am going to try installing the same printer 4 additional times with unique names and default settings. Not an elegant pythonic solution but should work.

If you're asking about printing PDFs that already exist rather than actually creating PDF files with python, I'd just look into generic windows ways to send a file to the printer. Hell, a quick google shows some results for "windows print pdf from command line", which you could just do from python.

CarForumPoster
Jun 26, 2013

⚡POWER⚡

QuarkJets posted:

Have you looked at pkipplib or win32print?


Thermopyle posted:

If you're asking about printing PDFs that already exist rather than actually creating PDF files with python, I'd just look into generic windows ways to send a file to the printer. Hell, a quick google shows some results for "windows print pdf from command line", which you could just do from python.

Yea the PDFs are already created with python. (A report, an envelope and a shipping label) Win32print is the pywin32 method that gets hilariously complicated quick. Sending a PDF to a printer that’s already configured is pretty easy. The problem is configuring the printer to do what I want (eg hole punch) from Python. I think the solution is “install 4 copies of the printer driver with different default configs” but can’t test until Monday.

CarForumPoster fucked around with this message at 01:05 on Jul 7, 2019

mr_package
Jun 13, 2000

QuarkJets posted:

If you use @dataclass, or classes at all, you're also kind of using dictionaries anyway so it's all gravy :shrug:

The fix is in that blog post (labeled Attempt 5), and I don't think "no way am I doing this" makes sense to say because fixing the issue only requires 1 additional line per @property. Specifically, you need to exclude the private attribute from __init__, which will allow the setter to get invoked when @dataclass assigns a value to the public version of the attribute. This is less intuitive than it could be (it would be nice if @dataclass could be smart enough to automagically identify that one of the attributes is a @property), but it makes sense when you understand what @dataclass and @property are doing.
Ok yeah on re-read it's not so bad, I was paying too much attention to the approaches that didn't work but in the end it's fairly simple, if not intuitive at first. It just seems so weird that it doesn't work normally out-of-the-box. @property / @x.setter are standard Python to me. I am really surprised they didn't engineer @dataclass to work with them by default.

Then there's this:

quote:

Caveat: this approach only holds because the property's setter is implemented. If we only implemented a getter (i.e. to make a read-only field), the __init__() method wouldn't be able to assign the attribute and would crash.
If @dataclass doesn't support @property is it really something we should consider fully baked? I don't buy the "it's not meant for read only" justification, for me, I wouldn't write something that breaks @property in this way, and I am worried really from maintenance point of view: this seems like something that's not quite right, seems like something they might fix later.... and I don't want to go back and fix my code to work with the NEW New Way Of Doing Things when they do. Maybe it's not a big deal, just seems odd to me, Spidey Sense or whatever.

QuarkJets
Sep 8, 2008

mr_package posted:

Ok yeah on re-read it's not so bad, I was paying too much attention to the approaches that didn't work but in the end it's fairly simple, if not intuitive at first. It just seems so weird that it doesn't work normally out-of-the-box. @property / @x.setter are standard Python to me. I am really surprised they didn't engineer @dataclass to work with them by default.

Then there's this:

If @dataclass doesn't support @property is it really something we should consider fully baked? I don't buy the "it's not meant for read only" justification, for me, I wouldn't write something that breaks @property in this way, and I am worried really from maintenance point of view: this seems like something that's not quite right, seems like something they might fix later.... and I don't want to go back and fix my code to work with the NEW New Way Of Doing Things when they do. Maybe it's not a big deal, just seems odd to me, Spidey Sense or whatever.

I consider it fully baked, because @dataclass is meant to be an extension of named tuples, and those don't support setters/getters at all. Given that, and given that @dataclass is a pretty new feature, I can forgive how the design didn't include a more intuitive interaction with @property, and it wouldn't surprise me if a future release fixed that. And based on how the interaction works today, I don't think that any future change to @dataclass is going to require that you modify old code, so it should be fine to use both together with the explicit understanding that either A) you need to define __init__ yourself (@dataclass provides more than just __init__, so this would still make sense to do) or B) allow the private attribute to be set by the __init__ created by @dataclass or C) ensure that the private attribute is excluded from the __init__ created by @dataclass and also have a setter.

Note that @dataclass does not break @property; the issue is simply that @dataclass doesn't know how to create a __init__ method that uses properties correctly, so you wind up in a weird situation where your private attribute is what's required by __init__. Properties explicitly allow that; if you want the private attribute to be set by __init__ for some reason, that's totally fine and supported.

QuarkJets fucked around with this message at 07:28 on Jul 7, 2019

mr_package
Jun 13, 2000
Thanks for your replies, I do not understand the guts of these things as well as you do and appreciate your time here.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

FWIW, I don't understand why the guy who wrote that blog post was so surprised or outraged that his working attempt worked. It's exactly how I would expect it to work.

I wouldn't worry about it.

SurgicalOntologist
Jun 17, 2004

Yeah, his attempt #5 is what I would try first. I see nothing alarming here, and I very much doubt Python will ever change dataclasses to make it easier to write properties. For one, this isn't actually about supporting properties in general, it's about supporting one specific use case for them, getters and setters. And the way to do it is pretty much the same as you would set up getters and setters in a normal class. As far as I can tell there isn't anything else that could be implemented to make it easier. After all, the need for a private attribute (and it's name) depends on the implementation of the properties. There's no way to infer it without some functionality that actually writes the properties for you...but then how would you customize?

mr_package
Jun 13, 2000
My interest in @property was really from Raymond H's talk "Python's Class Development Toolkit" where he talks about it being "a big big win for our language" so that's part of why I was so surprised by this. I've been going back and re-watching his talks now that I've been writing Python for a few years and it's been worthwhile obviously, picking up a lot of stuff I missed or didn't understand the first time.
https://www.youtube.com/watch?v=HTLu2DFOdTg&t=2272s

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

mr_package posted:

My interest in @property was really from Raymond H's talk "Python's Class Development Toolkit" where he talks about it being "a big big win for our language" so that's part of why I was so surprised by this. I've been going back and re-watching his talks now that I've been writing Python for a few years and it's been worthwhile obviously, picking up a lot of stuff I missed or didn't understand the first time.
https://www.youtube.com/watch?v=HTLu2DFOdTg&t=2272s

Just to be clear, I was criticizing the guy in that blog for being surprised and outraged about how to get them to work, not at you for being surprised that they don't work "out of the box" with dataclasses.

mr_package
Jun 13, 2000
Yeah no worries; I was just explaining why I was so surprised-- I had literally re-watched that vid the day before, made a mental note about @property/setter and got bit the next day trying to implement a @dataclass.

CarForumPoster
Jun 26, 2013

⚡POWER⚡
Appreciate your guy's help,

Thermopyle posted:

If you're asking about printing PDFs that already exist rather than actually creating PDF files with python, I'd just look into generic windows ways to send a file to the printer. Hell, a quick google shows some results for "windows print pdf from command line", which you could just do from python.

CarForumPoster posted:

I am going to try installing the same printer 4 additional times with unique names and settings. Not an elegant pythonic solution but should work.

This worked and is dead simple and pretty reliable. My printer or print spooler doesnt necessarily honor the order sent but a little bit of waiting fixed that.

CarForumPoster fucked around with this message at 12:39 on Jul 9, 2019

CarForumPoster
Jun 26, 2013

⚡POWER⚡
What I want to do: Convert a .docx file containing comments to pdf, displaying the Word comments in the PDF.

Why:I have a Flask web application on Heroku where a user uploads a .docx which is sent to S3 and the app adds comments to the .docx, then returns the PDF which is displayed in the browser.

The problem: Heroku runs on linux and LibreOffice doesnt print the PDF comments in a way thats pretty like Word on Win10 does, it instead embeds them as PDF comments.
In Win10 Word O365, this is trivial. You save it, which you can do easily from python.

I'm looking for the simplest/best solution to output a PDF with comments that looks like it does with Word.

A few things I'm considering:
-Have an Amazon Workspaces Win10 w/O365 running basically as a server and a Python script that somehow gets the files from S3, converts it on windows and returns the PDF to S3 and notifies my web app that the file is available for download. Not sure how to do this but seems possible.
-Trying a bunch of other Linux DOCX->PDF solutions to see if they're any better.
-Try installing MS Word on Heroku. Not sure if possible. (Update: It's Not)

EDIT:
Some better ideas possibly:
-Use MS Office Online to convert the Word Doc
-Find an API to do it for me.


EDIT2: Finding an API seems like the best solution but gently caress me if they dont suppress the comments output. Tried 3 so far. One works, but the docs are confusing. 2 Don't work.

EDIT3:
Solved it using Zamzar. Just so happens thats how their DOCX-PDF works and their docs are great.

CarForumPoster fucked around with this message at 20:00 on Jul 9, 2019

General_Failure
Apr 17, 2005
As an absolute python noob I wanted to do something that would motivate me.

I fed about 33000 trump tweets through textgenrnn. The results are horrible, but I feel some sense of achievement. It prompted me to work out how to use jupyter lab a bit more effectively and has encouraged me to add to the very basic example code.

Just thought I'd post that because I came here a while back asking about jupyter.

Adbot
ADBOT LOVES YOU

Hollow Talk
Feb 2, 2014

General_Failure posted:

As an absolute python noob I wanted to do something that would motivate me.

I fed about 33000 trump tweets through textgenrnn. The results are horrible, but I feel some sense of achievement. It prompted me to work out how to use jupyter lab a bit more effectively and has encouraged me to add to the very basic example code.

Just thought I'd post that because I came here a while back asking about jupyter.

Well, as people say about data: poo poo in, poo poo out. :v:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply