A better Python script for uploading images

Install the [poster] module by running the command-line:

sudo pip install poster


#!/usr/bin/env python

import urllib, urllib2, os, os.path, sys
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
from time import sleep


query = { 'id' : 1 }
url = "http://domain.com/path/save_image.php?"+urllib.urlencode(query)

filename = '/var/www/html/cam.jpg'
#print 'Saved: '+filename;

while True:
    if (os.path.isfile(filename)) :
      values = {'image':open(filename)}
      data, headers = multipart_encode(values)
      headers['User-Agent'] = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
      headers['filename'] = filename
      req = urllib2.Request(url, data, headers)
      req.unverifiable = True
      content = urllib2.urlopen(req).read()
    print 'Upload failed.';

Edit ~/.bashrc and add the following to the end of the file.

python ~/Documents/UploadImage.py &

Reboot the Raspberry PI and the security camera is ready to go!



if (!isset($_GET['id'])) {
  echo ('Invalid request!');
$id = intval($_GET['id']);

$image = $_FILES["image"];

if ($image == null) {
   echo ("Missing image!");
} else {
   echo "Saved image!";
   $filename = "image" . $id . ".jpg";
   $tmp_name = $_FILES["image"]["tmp_name"];
   move_uploaded_file($tmp_name, $filename);

3D Printers

[Quote: From Jed]

3D printers can print all sorts of plastics. For your application you could use PLA or PETG or ABS, I don’t think it would be necessary to do any of the really fancy stuff like Poly-carbonate, Flexables, or nylon. Here is a page with just specialty filaments [matterhackers Specialty Filament]

3d printers don’t get a lot less expensive when they get smaller. I’d recommend buying one that is a “standard” size. Right now that seems to be 200×250(8″ x 10″) or so. There are a lot of places that sell garbage as well, so you will want to be careful if you buy a kit. I’d recommend going to [prusa3d.com] and checking that out. I’ve heard good things about [cetus3d.com]

The features to look for are a heated bed that can go to 100C and a “all metal hotend”, even better if it is a genuine e3d.

I have a couple printers,

Taz 6 [lulzbot taz 6] ~2500
This one was the first one that I bought. It is fairly expensive, but it has a quite large build area(11.02 in x 11.02 in x 9.8 in). It prints quite well, and has all high quality components. It has a fairly large nozzle which limits it’s ability to print small details.

Prusa MK2S [prusa3d i3 kit] ~700 [forum]
This is the one I like the best. It prints well and reasonably quickly. It has a slightly smaller nozzle than the Taz so it can do detail better.

Monoprice Maker Ultimate (No web address, as I don’t recommend it at all) ~800
Doesn’t print well without constant management. Prints slowly with that constant management.