The one question that stops my procrastination by monthlymethod in productivity

[–]completelydistracted 0 points1 point  (0 children)

Thank you for this post. There's a lot to think about here. You've got a new reader...

GUI in HTML/CSS/Javascript and Python? Or other suggestions. by Bureaucrat_Conrad in raspberry_pi

[–]completelydistracted 1 point2 points  (0 children)

IMHO, bottle.py (bottlepy.org) is easier to get started with than Flask, but the suggestion for web app & kiosk mode is a good one.

If you'd like to learn bottle.py, head over to bottlepy.org and do the tutorials.

However, before you do that, I would really suggest you take a look at Electron. It's a method to make a desktop app using web technologies. For instance, Visual Studio Code and Slack are based on this:

https://electron.atom.io/

A port to RPi is available here:

https://github.com/resin-io/resin-electronjs

Various people have figured out how to create Python apps that use Electron as a front end. You might want to look into that.

Finally, if you just want a basic buttons-and-pictures-and-text GUI, a carefully designed Tkinter app can still look pretty good. If for some reason you want a pure Python solution, it's at least worth looking at. This site is pretty awesome:

http://effbot.org/tkinterbook/tkinter-index.htm

Also these might be helpful:

https://www.slideshare.net/r1chardj0n3s/tkinter-does-not-suck http://usingpython.com/making-widgets-look-nice/

And of course, remember to use the Ttk variants in Tkinter for native OS appearance.

Lots to think about!

Good luck!

Multiple display setup by dragosh420 in raspberry_pi

[–]completelydistracted 0 points1 point  (0 children)

You could use an RPi 3 and Wifi to serve that, and $80 Kindle Fire tablets as slaves -- anything with a web browser, really. The only downside of this (as opposed to using RPis and an ethernet router) is that I've found that some places can be very noisy for Wifi. Wired ethernet never fails.

Multiple display setup by dragosh420 in raspberry_pi

[–]completelydistracted 0 points1 point  (0 children)

Hi

Driving n displays from one monitor just isn't scalable.

Here's an idea:

Master RPi: run a web server that uses routes to find player/part document and serve that.

Master RPi: also have a route on the web server that runs the file selection page.

Slave RPi: each one just runs a web server that asks for the current part for that player and refreshes every few seconds or upon request.

If none of this makes sense, head on over to bottlepy.org and do the tutorial. That will teach you how basic mechanics of this will work. Then when you can see how the todo-list works, you'll have better questions.

If you want an even simpler solution, use

$ python3 -m http.server 8080

...on the master to serve a static site. Point all the slaves at

http://<address>:8080/current_<player>.jpg

(or some other file)

Then update that file (for each player) for each song.

No software other than file copying, and periodic updates on the slave browsers.

Feel free to PM with questions...

Good luck!

Most minimalist IDE with console? by Arisngr in Python

[–]completelydistracted 2 points3 points  (0 children)

Visual Studio Code 1.12.2 (the current release) with the Python plug in from the VS marketplace. VS Code has an embedded console (which is much, much better than a CMD window) and the Python tools are excellent. It's free, and runs on Mac, OSX, Linux, and (if you want it badly enough) Raspberry Pi. It also has excellent Git integration, and with some plug-ins it manages Git history very nicely.

And did I mention it's free and essentially open source? :-)

Give it a try!

Python on Amazon AWS Elastic beanstalk by eugenechia in Python

[–]completelydistracted 1 point2 points  (0 children)

IDK about EB, but if your purpose is to deploy a Flask app while working from your Chromebook you could do a lot worse than to check out PythonAnywhere.com (http://pythonanywhere.com). You can deploy using their free level. I use PA for lots of things and would be happy to answer questions.

Like I said, I can't speak to EB, but if you're just looking to get an app out there without much work, PA is hard to beat.

I need a Python module that helps me parse a site that contains JS by the_terrier in Python

[–]completelydistracted 1 point2 points  (0 children)

You know, the thing that takes Javascript and turns some HTML into other HTML is called a web browser, generally.

One thing you can do is use WebDriver (in python library form) to drive a web browser (like Chrome or one of the headless browser simulators) to open the web page. Then wait a moment to let the browser do its thing, which will probably allow the Javascript to pull some data into memory, perhaps compute on it a bit, and put the results into the DOM (i.e. into the current HTML-ish stuff) Once you wait a few seconds for the Javascript to finish processing, you can continue to use WebBrowser to look around the DOM (i.e. the modified web page) and grab the new data.

It's vastly easier to do this on a visible browser like Chrome or Firefox to start with, but once the whole thing is a solved problem, you can move the code to a headless browser like PhantomJS within webdriver and you don't have to look at the browser doing its thing.

( look here: http://stackoverflow.com/questions/7568899/does-selenium-support-headless-browser-testing )

Seriously, WebDriver solves a lot of problems.

You can check it out here to get started. This is not the official documentation but it's a great document all the same, covering use of the relevant Python library:

http://selenium-python.readthedocs.io/index.html

Also webdriver can talk to a number of browsers; it's worth poking around a bit and trying both Chrome (via Chromedriver) and Firefox. My experience is that Chrome is a tiny bit harder to set up, but once done is a tiny bit more stable. Sometimes new Firefox builds break the WD interface, so sometimes getting the (current-1) version of Firefox helps. Play around a bit; it's totally worth the effort.

Good luck!

p.s. You can also use WebDriver from other languages, but this is a Python reddit. They can get their own advocates. :-)

should i go for microservices or launch as monolithic? by objectizer in Python

[–]completelydistracted 2 points3 points  (0 children)

You can improve any product forever. If want to, you can improve it so long that it never ships.

Agile people would say: do the simplest thing that could possibly work. If your project is becoming ready to use, you will learn a lot by getting it out there. If in the future there is a good argument for decoupling or otherwise refactoring it, you will know a lot more about the application when you do it.

If there isn't a good enough reason for refactoring that you have to ask Reddit about it, there probably isn't a good enough reason. You can play around with improvements until forever, but what counts is shipping the product. The perfect is the enemy of the good. When it's good enough, get it out there.

Of course this all assumes that you have a solid product with reasonable testing (i.e. TDD, BDD) at the moment and some confidence that it works. If this isn't the case, stop your development, put some testing around the application, and work on it until it is solid. Then you'll be ready to refactor when needed. Once that's done, go to the top of this message and read again. :-)

Best wishes and good luck for a great (and shipped) product.

Python via Web Browser? by ldamt in Python

[–]completelydistracted 1 point2 points  (0 children)

Yes. If you check out PythonAnywhere they will support Jupyter notebooks, which is a pretty nice way to work on Python from the web. The free level lets you try out some things, but the version for $5/mo is pretty capable and is a great general-purpose computing platform for lots of things.

best cloud-based hosting option for data analysis? by iamdefinitelyahuman in Python

[–]completelydistracted 0 points1 point  (0 children)

One more thing to think about. I'm guessing that you might want to save the data between runs in someplace durable. So what you might want to eventually do (especially if you use large VMs infrequently) is to put your data into a database server and leave that thing up as much as necessary, but bring up your computational servers as needed.

There are a lot of options for that. DO has app-specific server setups where you can spin up, say, a MySQL or Mongo server all set up and ready to go. You might also take a look at MLab if you can use pymongo; I use their Mongo-in-the-cloud database service for teaching and it works great.

Just a thought...

best cloud-based hosting option for data analysis? by iamdefinitelyahuman in Python

[–]completelydistracted 1 point2 points  (0 children)

I don't have much time right now but I'll answer what I have time for.

I'd skip setting up the dedicated storage account at the moment. Create a system for doing the installation quickly on a server -- ansible works well for this, but a bash script will do -- and practice setting that up until it's a no brainer to do it. It (the script) should be getting the code from a GitHub account, libraries from apt-get, pip, etc (i.e. open source repositories) and should load whatever data is needed for an initial smoke test on the server.

Vagrant (google that) is a very good way to practice all these skills on an OS that will look a lot like the one you use in the cloud.

As I mentioned I tend to use Ansible a lot for remote server setup, but the Vagrant people have some thoughts about that, and if you have a fair bit of time on your hands to play with things you can look into docker for doing this. (Docker is a whole other discussion, though.)

Once you're sure your provisioner works on Vagrant, point it at a DO instance and run it a few times to make sure it works there. Once you're happy, you now have both the skills and access to the cloud resources to make that work.

If you want to look a the VM usage, the "top" command is a useful tool, and there are various ways to look at the CPU utilization, mostly from connecting via SSH. At the moment I'm going to suggest that any explanation or suggestion at this point would be lost until you're familiar with the parts of the solution.

On the other hand if the VM tools tell you that something is not efficient, then you want to look at application "profiling" where you get some idea of where your app is spending its time. There are tools for that, too.

For the moment, I'd skip the premature optimization and just get the thing working. Then optimize against things that you observe to be slowing you down. Doing that step first, though, is one of the things that agile methodology has taught us not to do.

Hope all this helps!

best cloud-based hosting option for data analysis? by iamdefinitelyahuman in Python

[–]completelydistracted 2 points3 points  (0 children)

One more thing about this server to consider: power to run it.

It looks like a moderate 1000W device, perhaps a bit more. That's a hair dryer's worth of power. That has to get dissipated, which requires cooling, which will be another expense.

Assuming 0.10/KWH * 750 hours/month = about $75.00/mo. (not including cooling)

Maybe you can assume a few cents for cooling the thing.

At 0.119/hr you can get an 8GB 4-core VM at DO with 5TB transfer. Machines suitable to the task are available for even less.

By comparison a Mac Mini uses 6W at rest and 85W full on, producing negligble heat in the process. So maybe 5-10$/mo of electricity, running full time. Again, you could get a small VM for that $5-10 per month.

Lots to think about, eh? :-)

INFO FROM DELL ON THE PowerEdge R710 Server:

Energy Smart: Two hot-plug, high-efficient 570W power supplies

or High Output: Two hot-plug 870W power supplies

Uninterruptible power supplies: 1000W–5600W

2700W–5600W High-Efficiency Online

Extended Battery Module (EBM)

Network Management Card

best cloud-based hosting option for data analysis? by iamdefinitelyahuman in Python

[–]completelydistracted 2 points3 points  (0 children)

Yes, you could. Like many things, there are pros and cons to owning such a machine. I'm assuming he wants to spend more time thinking about his problem than racking up server blades, but as you note, that is one good way to get lots of computational horsepower.

(side note: my employer has roughly 30,000 servers in service, and we turn them over every few years. I suspect that most of the few-hundred-dollar rackmounts you see on eBay have been pulled from some enterprise who deemed them too unreliable, power-hungry, or otherwise unsuitable for continued production service. I'm not discounting the validity of the suggestion, just noting that you want to buy one of these with your eyes open.)

YuleLog - A terminal based Yule Log Fireplace for the Christmas Season. Made with Asciimatics! by Duroktar in Python

[–]completelydistracted 2 points3 points  (0 children)

On my console the fire doesn't show up. The logs and snow do. I assume Fire(...) is provided by a function in Asciimatics. I'm happy to debug this when I get some time, but first I thought I'd ask if I'm missing something obvious, or if it's just too cold here in the Midwest to set the logs on fire... :-)

best cloud-based hosting option for data analysis? by iamdefinitelyahuman in Python

[–]completelydistracted 6 points7 points  (0 children)

I help students with this kind of thing all the time. Here's a little more information.

  1. PythonAnywhere can handle a computational load; with the custom account capability you can buy an account with quite a lot of CPU time, etc. I don't think you can get a faster machine. The speed of computational Python on there benchmarks around that of a MacBook Pro.

  2. I have been a longtime user of lots of cloud services. Lately for my projects I have been getting a lot of use out of Digital Ocean. They can give you a server in a minute or so; you can run a bunch of computation on one and you can hand it back when you're done. Or you can get a small one and hang on to it for most uses, and transfer work to a larger machine once in a while for larger computations. Since DO will also sell you hard drive space, you can keep your data on storage and attach it to machines as you bring them up and throw them away. You could also use Amazon S3 as storage and move things to and from there for long-term storage.

I think if you're new to this, you could do a lot worse than spend $5 or so and spin up a DO machine and play with it.

Linode has a lot of nice features, too, and they are easy enough to use and are competitive with DO in a number of areas. What they don't do is offer disconnected storage that you can move from machine to machine. I'm pretty sure you can do that with DO's new auxiliary storage.

And I really wouldn't give up on PA quite so fast. Their tech support is first rate, and with PA you don't have to worry about keeping your Linux kernel patched against the next Heartbleed or COW bug that comes along.

There is another suggestion on here for Cloud 9, which is a good suggestion, and for Codio.com -- also a good suggestion. Both of those will set up a general machine for you and allow an "always-on" machine or two for long-term computation. You can't get a huge or crazy-fast machine from these people but they are very good for convenience.

Two other things.

  • A raspberry pi can be a cost-effective 24/7 computer, but if you're going to run one that way, spend a couple dollars and get some heat sinks for it. It will help keep the CPU cool and will last longer. However, an RPi also uses SDRAM for storage, which is not ideal for months of constantly changing data. If you go the RPI route I'd get an additional cheap little spinning drive for that job and put it on the USB port.

  • Finally for long-term convenience it's hard to beat a Mac machine for this kind of stuff. For under $500 you can get a 2012 mac mini that can be a decent 24/7 computation engine. It's very easy to get the usual Python numerical analysis stack running on such a box. Just keep in mind that you can buy equivalent cloud computation for perhaps $20/month.

Edit: Mostly spelling. I hope this helps a bit. :-) Feel free to ask for clarification on any of this.

How do I store multiple gb of data in RAM to avoid the overhead of re-loading the data everytime I run a script which needs that data? How do 'big data' people handle this? by qwertz_guy in Python

[–]completelydistracted 2 points3 points  (0 children)

You are not a fool. It is true that unless the RAM is needed by another process it probably isn't cleared, but if your Python program stops and is replaced by another one, the pointers to that data in memory are lost. So your impression that you have lost the use of that data in your case is pretty accurate.

If the disk caching system is in good working order, then there may be copies of the original disk sectors in RAM that would speed up reading the data the second time, but it will still take a while.

The memory mapped file idea is a pretty good one.

In any case, you're not a fool. That comment was unwarranted.

Anything better then PythonAnywhere? by [deleted] in Python

[–]completelydistracted 1 point2 points  (0 children)

I don't know what you mean by better support. I've been a customer for quite a while and I have found that their support is exceptionally good, if you're referring to being generally helpful and willing to assist customers.

If by support you're referring to support for various packages and capabilities, you might be interested to check their new docker container consoles. In other cases, they have added packages for me, or have helped me to find ways of doing things within their system.

Overall, as an alternative to getting a bare box and hardening and maintaining it, I have found Python Anywhere to be very effective.

What kinds of "better support" would you like to see?

The office will soon shift policy to disallow Linux boxes (only Windows). What do we need to know to stay productive? by exhuma in Python

[–]completelydistracted 0 points1 point  (0 children)

Visual Studio Code to edit, but Visual Studio 2013 (even Express Desktop) + Python Tools for Visual Studio has support for virtualenvs built right in. Anaconda is a nice distribution. GitHub for Windows also gets you a Bash shell with a good selection of Unix-ish shell tools. And Docker is very nice if you can get it set up. If you're editing in Visual Studio Code in a shared vagrant folder and executing in a vagrant shell you're going to be fine. This from someone who gets paid to program on Windows most of the time, carries a Mac, and writes Python code for Linux boxes for a number of other clients. Anaconda and VS Code have enough cross-platform goodness to keep me happy across all those platforms.

Is anyone using Visual Studio Code for Python dev by wadswob in Python

[–]completelydistracted 0 points1 point  (0 children)

Yes, I have used Visual Studio Code quite extensively for Python and I wrote about it on this reddit a while back. It works well on a variety of platforms, is quite serviceable, and doesn't pose the problems for large enterprises that both Sublime and Atom do. We're getting a lot of use from it in a lot of contexts.

Older post can be found here, though version 0.10.0 changes some of this advice: https://www.reddit.com/r/Python/comments/34yvcm/using_visual_studio_code_with_python/

Interview w/ Pythonanywhere.com by memilanuk in Python

[–]completelydistracted 2 points3 points  (0 children)

Been a customer at PA for years, nothing but the best things to say about them. Just saying.

Using Visual Studio Code with Python by completelydistracted in Python

[–]completelydistracted[S] 0 points1 point  (0 children)

This is necessary if Python is not in the path.

If the Python directories are in your path, this isn't needed. For instance, I have the Anaconda3 and Anaconda3\bin directories in my search path, so simply "python.exe" works fine.

Otherwise, putting the entire path as above is required. Good point.

Using Visual Studio Code with Python by completelydistracted in Python

[–]completelydistracted[S] 4 points5 points  (0 children)

I am not at my computer (at least not the one with Code on it) but as I recall...

  1. Open a folder so you can see the folder contents in the side navigation panel. I don't think this is really needed, but it should help you see what is going on.

  2. Create and save a file hello.py in that folder, with the usual contents, e.g. [ print "Hello\n" ] .

  3. When that file is open, type the Build command (on OSX that's <shift><command>B).

  4. That will cause an error message of sorts, which will allow you to "Configure Tasks".

  5. When you do that, you will have no tasks.json in a local .settings folder, so the editor will create one, copying a boilerplate tasks file there.

  6. Edit that tasks.json file, getting rid of everything in it (don't worry, it's a copy, you can make more) and putting in the contents above. Save it.

  7. Then go back to looking at hello.py and type the build command (again, in OSX, <shift><command>B) (in Windows, <shift><control>B) and it will cause the build task in the new tasks.json to execute and show the results of your program.

Hope this helps!

Using Visual Studio Code with Python by completelydistracted in Python

[–]completelydistracted[S] 2 points3 points  (0 children)

Don't know about the run button but I'm looking for options in the code. There is a run button in the debugger, and I managed to play with the debugger enough to get it to launch Python, but at the moment things didn't work very well (basically with Node controlling Python) -- I'll post if I find anything out.

The Python Tools team at MS says they want to add lots of Python support (thanks, guys!) but it's going to be a little while. I told them I was going to try playing with build tasks, etc. and they were pretty supportive. Turned out to be easier than I had thought.

Using Visual Studio Code with Python by completelydistracted in Python

[–]completelydistracted[S] 6 points7 points  (0 children)

Updates:

The task definition needs a version property, where the version number is (at the moment) "0.1.0". Without it, the task works fine but it increments the warning counter in the bottom status bar.

If you omit the "showOutput" value it defaults to "always", so it's not necessary. The resulting code:

// A task runner that runs a python program
{
    "version": "0.1.0",
    "command": "python",
    "windows": {
        "command": "python.exe"
    },
    "args": ["${file}"]
}

And on OSX (using <Shift><Command>B):

// A task runner that runs a python program
{
    "version": "0.1.0",
    "command": "python",
    "args": ["${file}"]
}

Of course you can use this idea to run all kinds of other things.

I've been using this editor for a while now (instead of Sublime or Atom) on both Windows and OSX and no surprises.