diff --git a/src/main/java/GUI/GalleryCtl.java b/src/main/java/GUI/GalleryCtl.java index d1fe8fc..e4660b5 100644 --- a/src/main/java/GUI/GalleryCtl.java +++ b/src/main/java/GUI/GalleryCtl.java @@ -137,10 +137,6 @@ public class GalleryCtl { // Set the image aspect ratio to be preserved imageView.setPreserveRatio(true); - // Set the image to the image View - // TODO ist this ever used? - imageView.setImage(SOMLayout.LOGO_IMAGE); - // make it fit the height of the Screen imageView.setFitHeight(SOMLayout.screenHeight / 3); imageView.setFitWidth(SOMLayout.screenWidth / 4); diff --git a/src/main/java/GUI/PictureCtl.java b/src/main/java/GUI/PictureCtl.java index ddb861b..8b64e2e 100644 --- a/src/main/java/GUI/PictureCtl.java +++ b/src/main/java/GUI/PictureCtl.java @@ -275,8 +275,8 @@ public class PictureCtl { SOMImage somImage = somImageList.get(numberOfImages - 1); // update the Image State - // TODO Probably not necessary - somImage.updateImageState(); +// TODO Probably not necessary -- commented out to test it +// somImage.updateImageState(); // Scale the Image if needed ScaleWorker.scale(somImage, ScaleWorker.PREVIEW); diff --git a/src/main/java/model/SOMConfig.java b/src/main/java/model/SOMConfig.java index c001ecc..96cefe1 100644 --- a/src/main/java/model/SOMConfig.java +++ b/src/main/java/model/SOMConfig.java @@ -24,7 +24,6 @@ public class SOMConfig { @XmlElement(name = "UPLOAD_PATH") public static final String UPLOAD_PATH = getEventPicDir(); // The Box's ID - // Todo Throw out!! or by MAC Adress @XmlElement(name = "BOX_ID") public static final String BOX_ID = MachineWorker.getHostName(); // Number of pictures in series mode @@ -41,12 +40,12 @@ public class SOMConfig { public static final String CLOUD_CREDENTIALS = "upload:geheim"; // Make the Scaling Algorithm switchable public static final int SCALING_GRAPHICS_2D = 0; - public static final int SCALING_IMAGE_ICON = 1; - public static final int SCALING_JAVAFX = 2; + public static final int SCALING_JAVAFX = 1; + public static final int SCALING_ALGORITHM = SCALING_GRAPHICS_2D; + public static final String CLOUD_ADDRESS = "https://cloud.selfomat.de/remote.php/webdav/"; // Path to configfile - //TODO Resource?? - private static final File configfile = new File(SOMLayout.class.getResource("/config/config.xml").getFile()); + private static final File configfile = new File(("config/config.xml")); // Instance private static SOMConfig config = null; @@ -82,11 +81,6 @@ public class SOMConfig { File picturesPath = SOMConfig.PICTURES_PATH; -// File eventPicDir = new File(picturesPath.toString() + "/" + timeString -// + "/" + MachineWorker.getHostName()); - // TODO catch possible fail -// eventPicDir.mkdirs(); - String eventPicDir = picturesPath.toString() + "/" + timeString + "/" + MachineWorker.getHostName(); @@ -96,8 +90,6 @@ public class SOMConfig { // Write Config private void writeConfig() { try { - - // TODO catch possible fail configfile.getParentFile().mkdirs(); JAXBContext jaxbContext = JAXBContext.newInstance(SOMConfig.class); diff --git a/src/main/java/model/SOMLayout.java b/src/main/java/model/SOMLayout.java index b83a233..09b57da 100644 --- a/src/main/java/model/SOMLayout.java +++ b/src/main/java/model/SOMLayout.java @@ -20,9 +20,9 @@ public class SOMLayout { public static final javafx.scene.image.Image SERIES_PHOTO_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_CaptureSeries.png").toString()); public static final javafx.scene.image.Image PRINT_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Print.png").toString()); public static final javafx.scene.image.Image PICTURE_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Picture.png").toString()); - public static final javafx.scene.image.Image SMILE_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Smiley.png").toString()); //TODO LINK right image - public static final javafx.scene.image.Image BACK_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Back.png").toString()); //TODO LINK right image - public static final javafx.scene.image.Image FORTH_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Forth.png").toString()); //TODO LINK right image + public static final javafx.scene.image.Image SMILE_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Smiley.png").toString()); + public static final javafx.scene.image.Image BACK_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Back.png").toString()); + public static final javafx.scene.image.Image FORTH_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Forth.png").toString()); //CI public static final javafx.scene.image.Image LOGO_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMLogo.png").toString()); // public static final javafx.scene.image.Image SPLASH_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMSplash.jpg").toString()); diff --git a/src/main/java/workers/FilesWorker.java b/src/main/java/workers/FilesWorker.java index 9989bb0..0abbb4a 100644 --- a/src/main/java/workers/FilesWorker.java +++ b/src/main/java/workers/FilesWorker.java @@ -51,7 +51,6 @@ public class FilesWorker { public static File getSourcePath() { File src = new File(SOMConfig.PICTURES_PATH.toString() + "/src"); - // TODO catch possible fail src.mkdirs(); return src; } @@ -65,7 +64,6 @@ public class FilesWorker { public static File getPreviewPath() { File prv = new File(SOMConfig.PICTURES_PATH.toString() + "/prv"); - // TODO catch possible fail prv.mkdirs(); return prv; } @@ -79,7 +77,6 @@ public class FilesWorker { public static File getThumbPath() { File tmb = new File(SOMConfig.PICTURES_PATH.toString() + "/tmb"); - // TODO catch possible fail tmb.mkdirs(); return tmb; } @@ -93,7 +90,6 @@ public class FilesWorker { public static File getFinalPath() { File fnl = new File(SOMConfig.PICTURES_PATH.toString() + "/fnl"); - // TODO catch possible fail fnl.mkdirs(); return fnl; } @@ -107,7 +103,6 @@ public class FilesWorker { public static File getTempPath() { File tmp = new File(SOMConfig.PICTURES_PATH.toString() + "/tmp"); - // TODO catch possible fail tmp.mkdirs(); return tmp; } @@ -136,6 +131,9 @@ public class FilesWorker { public static void upload() { try { + // Backup the Backup + + // Get all Files in the image Folder List images = allFilesForUpload(); // Lists for either dirs or pictures @@ -231,7 +229,6 @@ public class FilesWorker { } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); @@ -246,12 +243,10 @@ public class FilesWorker { System.out.println("LAUNCH Upload Process: " + i); final File file = files.get(i); - final String target = "https://cloud.selfomat.de/remote.php/webdav/" + SOMConfig.getEventPicDir() + "/" + file.getName(); + final String target = SOMConfig.CLOUD_ADDRESS + SOMConfig.getEventPicDir() + "/" + file.getName(); - System.out.println(file.toString()); - System.out.println("----------->"); - System.out.println(target); System.out.println(""); + System.out.println(file.toString() + "----------->" + target); System.out.println(""); final int pictureCounter = i + 1; @@ -261,6 +256,7 @@ public class FilesWorker { protected Boolean call() throws Exception { // build the upload process // TODO remove -k option (this option skips certificate verification) + // TODO Make Software run in SELFOMAT Directory ProcessBuilder builder = new ProcessBuilder( "bash", "SELFOMAT/sh/upload.sh", @@ -288,6 +284,7 @@ public class FilesWorker { } else { // process ended failing // TODO Catch failed uploads + System.out.println("process ended failing " + file); Thread.sleep(1000); return false; @@ -306,7 +303,6 @@ public class FilesWorker { threads[i].join(); i++; } -//TODO Catch fails } private static void uploadDir(final List dirs) throws Exception { @@ -326,10 +322,10 @@ public class FilesWorker { // TODO remove -k option (this option skips certificate verification) ProcessBuilder builder = new ProcessBuilder("curl", "-u", - "upload:geheim", + SOMConfig.CLOUD_CREDENTIALS, "-X", "MKCOL", - "https://cloud.selfom.at/remote.php/webdav/" + SOMConfig.getEventPicDir(), + SOMConfig.CLOUD_ADDRESS + SOMConfig.getEventPicDir(), // dir.toString().replace("/src", ""), "-k"); @@ -385,7 +381,6 @@ public class FilesWorker { return new ArrayList(filesAndDirs); } - // TODO static?? public static SOMImage waitForImageAndCapture() { //Behandelt try { @@ -456,7 +451,7 @@ public class FilesWorker { // Check that filename is the same as expected image && !fileName.toString().equals( newImage.getSrc().getName())) { - // TODO Catch wrong pictures, only for testing + // TODO Catch wrong pictures, only for testing, make only available for Developer (Hostname??) // Hide the Progress Indicator SOMGUI.captureCtl.pictureLoadIndicator.setVisible(false); // Set back the Progress Indicator diff --git a/src/main/java/workers/ScaleWorker.java b/src/main/java/workers/ScaleWorker.java index 5d167d1..e05bea0 100644 --- a/src/main/java/workers/ScaleWorker.java +++ b/src/main/java/workers/ScaleWorker.java @@ -209,18 +209,12 @@ public class ScaleWorker extends Thread { // Print the File Path System.out.println(sourceFile.toString()); - // Print the Sizes - System.out.println("Size now: " + sourceWidth + "px X " + sourceHeight + "px"); - System.out.println("Size between: " + scaledSourceWidth + "px X " + scaledSourceHeight + "px"); - System.out.println("Size after: " + targetWidth + "px X " + targetHeight + "px"); - // SCALE ----------------------------------------------------------- // THE ------------------------------------------------------------- // SOURCE ---------------------------------------------------------- // Get the ImageIcon Image sourceImageIconImage = sourceImageIcon.getImage(); - System.out.println("Got the ImageIcon"); // Open a buffered Image in the specified size // (with no data at this point --> black image) @@ -229,29 +223,21 @@ public class ScaleWorker extends Thread { scaledSourceHeight, BufferedImage.TYPE_INT_RGB ); - System.out.println("Got the BufferedImage"); // Get the Graphics2D scaledSourceGraphics = scaledSourceBufferedImage.createGraphics(); - System.out.println("Got the Graphics2D"); // Set the Rendering hints scaledSourceGraphics.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ); - System.out.println("Rendering Hints Set"); // Actually Scale the Image scaledSourceGraphics.drawImage(sourceImageIconImage, 0, 0, scaledSourceWidth, scaledSourceHeight, null); - System.out.println("IMAGE SCALED"); scaledSourceGraphics.dispose(); // System Resources Released - // TODO Can we use this for perormance?? - - System.out.println("Got the target Image Icon"); - // Calculate the Offsets int wOffset; @@ -269,10 +255,6 @@ public class ScaleWorker extends Thread { wOffset = 0; } - System.out.println("Got the Offset for cropping"); - - System.out.println("Get the Crop Image Filter"); - CropImageFilter cropimgf = new CropImageFilter( // Crop by moving the image half the way // it is wider to the left @@ -285,30 +267,18 @@ public class ScaleWorker extends Thread { targetHeight ); - System.out.println("Ready"); - - System.out.println("Get the Filtered image Source"); - FilteredImageSource producer = new FilteredImageSource( scaledSourceBufferedImage.getSource(), cropimgf ); - System.out.println("Ready"); - - System.out.println("Get the target Image"); Image image = Toolkit.getDefaultToolkit().createImage( producer ); - System.out.println("Ready"); - System.out.println("Get the target image Icon"); - targetImageIcon = new ImageIcon( // TODO Veeeery slow on raspberry + targetImageIcon = new ImageIcon( image ); - System.out.println("Ready"); - // TODO Check if there is something in the Image Icon on RPi - System.out.println("IMAGE CROPPED"); // save the smaller image croppedBufferedImage = new BufferedImage( @@ -317,38 +287,23 @@ public class ScaleWorker extends Thread { BufferedImage.TYPE_INT_RGB ); - System.out.println("Got the BufferedImage after CROPPING"); croppedGraphics = croppedBufferedImage.getGraphics(); - System.out.println("Got the Graphics"); croppedGraphics.drawImage(targetImageIcon.getImage(), 0, 0, null); - System.out.println("Graphics drawn"); - // WRITE --------------------------------------------------------------- // THE ----------------------------------------------------------------- // IMAGE --------------------------------------------------------------- - System.out.println("Writing Thumb"); - - System.out.println("Trying to write image to " + targetFile.toString()); - System.out.println(croppedBufferedImage.toString()); - // TODO Breaking up at this point on the RPi --> Look at older ScaleWorker - writeJPEG(targetFile, croppedBufferedImage); - System.out.println("Image Writer returned: " -// + iw - ); - - // UPDATE --------------------------------------------------------------- // IMAGE ---------------------------------------------------------------- // STATE ---------------------------------------------------------------- somImage.updateImageState(); - System.out.println("Image State Updated"); + System.out.println("Image State Updated: Scaled"); // Clean up croppedGraphics.dispose(); @@ -361,127 +316,6 @@ public class ScaleWorker extends Thread { break; } - case SOMConfig.SCALING_IMAGE_ICON: { -// // IMAGE ICON ---------------------------------------------------------- -// // Generate an ImageIcon from the Source File -// sourceImage = new javafx.scene.image.Image(sourceFile.toString()); -// // the sources original width and height -// sourceWidth = sourceImage.getWidth(); -// sourceHeight = sourceImage.getHeight(); -// -// // Calculate the aspect ratio before cropping -// sourceAspect = (sourceWidth) / (sourceHeight); -// // Calculate the ImageViews' cropped aspect ratio -// targetAspect = ((double) targetWidth) / ((double) targetHeight); -// -// // if picture is higher than frame -// if (sourceAspect < targetAspect) { -// scaledSourceHeight = (int) Math.ceil(targetWidth / sourceAspect); -// scaledSourceWidth = targetWidth; -// } -// -// // if Picture is narrower (or equal) -// else { -// scaledSourceWidth = (int) Math.ceil(targetHeight * sourceAspect); -// scaledSourceHeight = targetHeight; -// } -// -// //Way too slow for the RPi -// System.out.println("Scale with ImageIcon"); -// -// // Scale to right size, -// // no cropping -// targetImageIcon = new ImageIcon( -// sourceImageIcon.getImage().getScaledInstance( -// scaledSourceWidth, scaledSourceHeight, -// Image.SCALE_FAST -// )); -// -// -// // Calculate the Offsets -// int wOffset; -// int hOffset; -// -// // ---------- -// // Crop Image -// if (sourceAspect > targetAspect) { -// hOffset = 0; -// wOffset = (scaledSourceWidth - targetWidth) / 2; -// } else { -// hOffset = (scaledSourceHeight - targetHeight) / 2; -// wOffset = 0; -// } -// -// System.out.println("Got the Offset for cropping"); -// -// System.out.println("Get the Crop Image Filter"); -// CropImageFilter cropimgf = new CropImageFilter( -// // Crop by moving the image half the way -// // it is wider to the left -// wOffset, -// // Crop by moving the image half the way -// // it is higher to the top -// hOffset, -// -// targetWidth, -// targetHeight -// ); -// System.out.println("Ready"); -// -// System.out.println("Get the Filtered image Source"); -// FilteredImageSource producer = new FilteredImageSource( -// sourceImageIcon.getImage().getSource(), -// cropimgf -// ); -// System.out.println("Ready"); -// -// System.out.println("Get the target Image"); -// Image image = Toolkit.getDefaultToolkit().createImage( -// producer -// ); -// System.out.println("Ready"); -// -// System.out.println("Get the target image Icon"); -// targetImageIcon = new ImageIcon( // TODO Veeeery slow on raspberry -// image -// ); -// System.out.println("Ready"); -// // TODO Check if there is something in the Image Icon on RPi -// System.out.println("IMAGE CROPPED"); -// -// // save the smaller image -// BufferedImage bufferedImage = new BufferedImage( -// targetWidth, -// targetHeight, -// BufferedImage.TYPE_INT_RGB -// ); -// -// System.out.println("Got the BufferedImage after CROPPING"); -// croppedGraphics = bufferedImage.getGraphics(); -// System.out.println("Got the Graphics"); -// -// croppedGraphics.drawImage(targetImageIcon.getImage(), 0, 0, null); -// -// System.out.println("Graphics drawn"); -// -// System.out.println("Writing Thumb"); -// -// System.out.println("Trying to write image to " + targetFile.toString()); -// System.out.println(bufferedImage.toString()); -// // TODO Breaking up at this point on the RPi --> Look at older ScaleWorker -// -// writeJPEG(targetFile, bufferedImage); -// -// System.out.println("Image Writer returned: " -//// + iw -// ); -// somImage.updateImageState(); -// -// System.out.println("Image State Updated"); -// -// somImage.updateImageState(); - break; - } // JAVAFX ---------------------------------------------------------- case SOMConfig.SCALING_JAVAFX: { // Scale with javafx @@ -493,7 +327,7 @@ public class ScaleWorker extends Thread { somImage.updateImageState(); - System.out.println("Image State Updated"); + System.out.println("Image State Updated: Scaled"); somImage.updateImageState(); break; diff --git a/src/main/resources/sh/gphoto2-updater.sh b/src/main/resources/sh/gphoto2-updater.sh new file mode 100644 index 0000000..f21048b --- /dev/null +++ b/src/main/resources/sh/gphoto2-updater.sh @@ -0,0 +1,271 @@ +#!/bin/bash + +# Gphoto2 compiler and installer script +# +# This script is specifically created for Raspbian http://www.raspbian.org +# and Raspberry Pi http://www.raspberrypi.org but should work over any +# Debian-based distribution + +# Created and mantained by Gonzalo Cao Cabeza de Vaca +# Please send any feedback or comments to gonzalo.cao(at)gmail.com +# Updated for gPhoto2 2.5.1.1 by Peter Hinson +# Updated for gPhoto2 2.5.2 by Dmitri Popov +# Updated for gphoto2 2.5.5 by Mihai Doarna +# Updated for gphoto2 2.5.6 by Mathias Peter +# Updated for gphoto2 2.5.7 by Sijawusz Pur Rahnama +# Updated for gphoto2 2.5.8 by scribblemaniac +# Updated for gphoto2 2.5.9 at GitHub by Gonzalo Cao +# Updated for last development release at GitHub by Gonzalo Cao +# Updated for gphoto2 2.5.10 by Gonzalo Cao + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +latest_stable_version=2_5_10 +display_version=$(echo ${latest_stable_version} | tr '_' '.') +branch_libgphoto='' +branch_gphoto='' + +if [ "$(whoami)" != "root" ]; then + echo "Sorry, this script must be executed with sudo or as root" + exit 1 +fi + +usage() +{ +cat << EOF +usage: sudo $0 [-h|--help|-s|--stable|-d|--development] + +-h|--help: this help message +-s|--stable: select the stable version: ${display_version} +-d|--development: select the latest develoment version + +Note: An interactive menu is displayed if no parameter is given. +EOF +exit 1 +} + +parse_options() +{ +if ! all_options=$(getopt -o hds -l help,development,stable -- "$@") +then + usage +fi +eval set -- "$all_options" + +while true +do + case "$1" in + -h|--help) usage;; + -d|--development) shift 1;; + -s|--stable) branch_libgphoto="--branch libgphoto2-${latest_stable_version}-release" + branch_gphoto="--branch gphoto2-${latest_stable_version}-release" + shift 1;; + --) break ;; + esac +done +} + +menu() +{ +PS3='Please enter your choice: ' +options=("Install last development version" + "Install last stable release (${display_version})" + "Quit") + +select opt in "${options[@]}" +do + case $opt in + "Install last development version") + echo + echo "\"Install last development version\" selected" + echo + break + ;; + "Install last stable release (${display_version})") + echo + echo "\"Install last stable release (${display_version})\" selected" + echo + branch_libgphoto="--branch libgphoto2-${latest_stable_version}-release" + branch_gphoto="--branch gphoto2-${latest_stable_version}-release" + break + ;; + "Quit") + exit 0 + ;; + *) echo invalid option;; + esac +done +} + +# Display the menu if the script was called without any parameters +# else try to parse the options +if [ $# -eq 0 ] +then + menu +else + parse_options "$@" +fi + +echo +echo "----------------" +echo "Updating sources" +echo "----------------" +echo + +apt-get update -qq + +echo +echo "-----------------------------------------" +echo "Removing gphoto2 and libgphoto2 if exists" +echo "-----------------------------------------" +echo + +apt-get remove -y gphoto2 libgphoto2-port10 + +echo +echo "-----------------------" +echo "Installing dependencies" +echo "-----------------------" +echo + +apt-get install -y build-essential libltdl-dev libusb-dev libexif-dev libpopt-dev libudev-dev pkg-config git automake autoconf autopoint gettext libtool wget + +echo +echo "-------------------------" +echo "Creating temporary folder" +echo "-------------------------" +echo + +mkdir gphoto2-temp-folder +cd gphoto2-temp-folder + +echo "gphoto2-temp-folder created" + + +echo +echo "----------------------" +echo "Downloading libgphoto2" +echo "----------------------" +echo + +if (git clone $branch_libgphoto https://github.com/gphoto/libgphoto2.git) + then + cd libgphoto2/ + else + echo "Unable to get libgphoto2" + echo "Exiting..." + exit 1 +fi + + +echo +echo "-----------------------------------" +echo "Compiling and installing libgphoto2" +echo "-----------------------------------" +echo + +autoreconf --install --symlink +./configure +make -j "$cores" +make install +cd .. + +echo +echo "-------------------" +echo "Downloading gphoto2" +echo "-------------------" +echo + +if (git clone $branch_gphoto https://github.com/gphoto/gphoto2.git) + then + cd gphoto2 + else + echo "Unable to get gphoto2" + echo "Exiting..." + exit 1 +fi + + +echo +echo "--------------------------------" +echo "Compiling and installing gphoto2" +echo "--------------------------------" +echo + +autoreconf --install --symlink +./configure +make -j "$cores" +make install +cd .. + +echo +echo "-----------------" +echo "Linking libraries" +echo "-----------------" +echo + +ldconfig + +echo +echo "---------------------------------------------------------------------------------" +echo "Generating udev rules, see http://www.gphoto.org/doc/manual/permissions-usb.html" +echo "---------------------------------------------------------------------------------" +echo + +udev_version=$(udevd --version) + +if [ "$udev_version" -ge "201" ] +then + udev_rules=201 +elif [ "$udev_version" -ge "175" ] +then + udev_rules=175 +elif [ "$udev_version" -ge "136" ] +then + udev_rules=136 +else + udev_rules=0.98 +fi + +/usr/local/lib/libgphoto2/print-camera-list udev-rules version $udev_rules group plugdev mode 0660 > /etc/udev/rules.d/90-libgphoto2.rules + +if [ "$udev_rules" = "201" ] +then + echo + echo "------------------------------------------------------------------------" + echo "Generating hwdb file in /etc/udev/hwdb.d/20-gphoto.hwdb. Ignore the NOTE" + echo "------------------------------------------------------------------------" + echo + /usr/local/lib/libgphoto2/print-camera-list hwdb > /etc/udev/hwdb.d/20-gphoto.hwdb +fi + + +echo +echo "-------------------" +echo "Removing temp files" +echo "-------------------" +echo + +cd .. +rm -r gphoto2-temp-folder + + + +echo +echo "--------------------" +echo "Finished!! Enjoy it!" +echo "--------------------" +echo + +gphoto2 --version diff --git a/src/main/resources/sh/print.sh b/src/main/resources/sh/print.sh new file mode 100644 index 0000000..82e0d15 --- /dev/null +++ b/src/main/resources/sh/print.sh @@ -0,0 +1 @@ +lp -d Canon_CP910 $1 diff --git a/src/main/resources/sh/startSOM.sh b/src/main/resources/sh/startSOM.sh new file mode 100644 index 0000000..20e581f --- /dev/null +++ b/src/main/resources/sh/startSOM.sh @@ -0,0 +1,8 @@ +#!/bin/bash +gvfs-mount -s gphoto2 + +cd ~/ +#java -jar /home/pi/SELFOMAT/selfomat-single-user-0.3.0.7-SNAPSHOT-jar-with-dependencies.jar +#java -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.vk.adjustwindow=true -jar /home/pi/SELFOMAT/selfomat-single-user-0.3.0.11-SNAPSHOT-jar-with-dependencies.jar +#sudo java -jar /home/pi/SELFOMAT/selfomat-single-user-0.3.0.19-SNAPSHOT-jar-with-dependencies.jar +sudo java -Dmonocle.input.3/eef/1/100.flipXY=false -Dmonocle.inpu100.minX=89 -Dmonocle.input.3/eef/1/100.maxX=1945 -Dmonocle.input.3/eef/1/100.maxY=178 -Dmonocle.input.3/eef/1/100.minY=1816 -jar SELFOMAT/selfomat-single-user-0.4.0.11-SNAPSHOT-jar-with-dependencies.jar diff --git a/src/main/resources/sh/upload.sh b/src/main/resources/sh/upload.sh index 79f0d5a..e67da9c 100644 --- a/src/main/resources/sh/upload.sh +++ b/src/main/resources/sh/upload.sh @@ -1,43 +1,82 @@ -#!/bin/bash +#!/bin/sh # Upload files to a webdav storage, # check them by an MD5 Hash # and remove the local copy afterwards. + if [ "$1" == "-h" ]; -then -echo "Syntax:" -echo "upload.sh [Local File Location] [Remote File Location] [username:password]" + then + echo "Syntax:" + echo "upload.sh [Local File Location] [Remote File Location] [username:password]" -elif [ $1 = $2 ]; -then -echo "Source and Target are the same" -echo "No Arguments provided!" + elif [ $1 = $2 ]; + then + echo "Source and Target are the same" + echo "No Arguments provided!" -else -#upload the image -curl -T $1 -u $3 $2 -k + -# get the online images' MD5up -online_md5=$(curl $2 -k -u $3 | md5sum | awk '{print $1}') + else + + STAMP=$(date "+%Y%m%d-%H%M%S") + + echo $STAMP + + # get the online images' MD5 + pre_online_md5=$(curl $2 -k -u $3 | md5sum | awk '{print $1}') -# get the local images' MD5 -local_md5=$(md5sum "$1" | awk '{print $1}') + # get the local images' MD5 + pre_local_md5=$(md5sum "$1" | awk '{print $1}') -# compare both MD5s -echo "$online_md5" -echo "$local_md5" + # compare both MD5s + echo "$pre_online_md5" + echo "$pre_local_md5" + + #check if the file already exists + if curl --head -u $3 --fail $2 -k; + then + ## it exists + + echo "FILE ALREADY EXISTS" + + # Check if it is the same already + if [ "$pre_online_md5" != "$pre_local_md5" ]; + then + # FILES DIFFER FROM EACH OTHER + # if not move the online file + + echo "RANAMING FILE TO $2.$STAMP" + + curl -u $3 -k -X MOVE --header "Destination:$2.$STAMP" $2 + fi + fi + + # IF THERE WAS ANOTHER IMAGE, NOW IT SHOULD BE RENAMED + + echo "UPLOAD FILE" + curl -u $3 -T $1 $2 -k + + # get the online images' MD5 + online_md5=$(curl $2 -k -u $3 | md5sum | awk '{print $1}') -if [ "$online_md5" == "$local_md5" ]; -# Remove the original Image if successful -then -echo "Uploaded successfully!" + # get the local images' MD5 + local_md5=$(md5sum "$1" | awk '{print $1}') -# Remove Original -rm $1 + # compare both MD5s + echo "$online_md5" + echo "$local_md5" -# Fallback routine if not successful -else -echo "Upload failed!!" -fi + if [ "$online_md5" == "$local_md5" ]; + # Remove the original Image if successful + then + echo "Uploaded successfully!" + + # Remove Original + rm $1 + + # Fallback routine if not successful + else + echo "Upload failed!!" + fi fi