Skip to content

Commit

Permalink
Changing some configuration aspects and refactoring of the files.
Browse files Browse the repository at this point in the history
- Changed default address to 127.0.0.1
- Fix zoom issue and now default value is 4.
- Lexicographical order of defaultProjectConfig (visual enhancement)
- Refactoring files:
	- Removing duplicates model & models.
	- Removing duplicates services/utils & utils.
	- New folders for structure.
- Other minor changes
  • Loading branch information
melalonso authored and melalonso committed Sep 5, 2016
1 parent 624a52b commit 387309b
Show file tree
Hide file tree
Showing 42 changed files with 52 additions and 203 deletions.
12 changes: 0 additions & 12 deletions src/configuration/config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
email-receiver: librescan@gmail.com
scantailor:
l: 1.5
margins-left: 2.5
margins-right: 2.5
margins-top: 2.5
margins-bottom: 2.5
dewarping: auto
despeckle: off
dpi-x: 300
dpi-y: 300
threshold: 0
color-mode: black_and_white
project:
path: /home/sd/LibreScanProjects
last-id: 1
Expand Down
28 changes: 14 additions & 14 deletions src/configuration/defaultProjectConfig.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
camera:
zoom: 10
iso: 0
last-pic-number: 0
zoom: 0
general-info:
description: description
name: name
output-formats:
- pdfbeads
scantailor:
color-mode: black_and_white
despeckle: off
dewarping: auto
dpi-x: 300
dpi-y: 300
l: 1.5
margins-bottom: 2.5
margins-left: 2.5
margins-right: 2.5
margins-top: 2.5
margins-bottom: 2.5
dewarping: auto
despeckle: off
dpi-x: 300
dpi-y: 300
threshold: 0
color-mode: black_and_white
tesseract:
lang: spa
output-format: hocr
input-extension: tif
general-info:
name: name
description: description
output-formats:
- pdfbeads
lang: spa
output-format: hocr
9 changes: 0 additions & 9 deletions src/model/camera.py

This file was deleted.

11 changes: 0 additions & 11 deletions src/model/config.py

This file was deleted.

7 changes: 0 additions & 7 deletions src/model/mail.py

This file was deleted.

7 changes: 0 additions & 7 deletions src/model/photo.py

This file was deleted.

9 changes: 0 additions & 9 deletions src/model/project.py

This file was deleted.

6 changes: 0 additions & 6 deletions src/model/projectSummary.py

This file was deleted.

9 changes: 9 additions & 0 deletions src/models/cameraConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@ class CameraConfig:
def __init__(self, p_zoom, p_iso):
self.zoom = p_zoom
self.iso = p_iso
'''
self.focus_distance = p_focusDistance
self.shutter_speed = p_shutterSpeed
self.dpi = p_dpi
self.sensibility = p_sensibility
self.raw = p_raw
self.monochromatic = p_monochromatic
self.flip = p_flip
'''
2 changes: 1 addition & 1 deletion src/models/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class Mail:

def __init__(self, p_name, p_sender, p_phone, p_msg):
self.name = p_name
self.sender_mail = p_sender
self.sender = p_sender
self.phone = p_phone
self.msg = p_msg
3 changes: 1 addition & 2 deletions src/services/mailService.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MailService(metaclass=Singleton):
server = "localhost"

def get_email_receiver(self):
return "melvin.aep@hotmail.com"
return "librescan@gmail.com"

# Formats the mail msg with the sender information and the body msg.
def prepare_msg(self, p_name, p_msg, p_phone, p_from):
Expand All @@ -16,7 +16,6 @@ def prepare_msg(self, p_name, p_msg, p_phone, p_from):
Tel: %s
Cuerpo del mensaje: %s
""" % (p_name, p_from, p_phone, p_msg)
print(msg)
return msg

def send(self, mail):
Expand Down
4 changes: 2 additions & 2 deletions src/services/outputService.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from utils.pdfBeads import PDFBeads
from utils.outputPreparer import OutputPreparer
from utils.output.impl.pdfBeads import PDFBeads
from utils.output.outputPreparer import OutputPreparer
from patterns.singleton import Singleton
import threading

Expand Down
3 changes: 2 additions & 1 deletion src/services/projectService.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


class ProjectService(metaclass=Singleton):

def __init__(self):
self.config_folder = os.environ["HOME"] + "/.librescan"
self.project_path = None
Expand All @@ -24,6 +25,7 @@ def create(self, p_project):
# Creates the project config template with default values.
src = self.config_folder + "/defaultProjectConfig.yaml"
destiny = new_project_path + "/.projectConfig.yaml"

os.system("cp " + src + " " + destiny)
os.system("touch " + new_project_path + "/.pics.ls")
os.system("touch " + new_project_path + "/.toDelete.ls")
Expand Down Expand Up @@ -56,7 +58,6 @@ def remove(self, p_id):
def load(self, p_project_path):
self.project_path = p_project_path
pics_file = self.project_path + '/.pics.ls'
print(pics_file)
f = open(pics_file, "r")
contents = f.readlines()
f.close()
Expand Down
2 changes: 1 addition & 1 deletion src/services/queueService.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from queue import Queue
import threading
from queue import Queue
from patterns.singleton import Singleton


Expand Down
5 changes: 3 additions & 2 deletions src/services/scannerService.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from models.cameraConfig import CameraConfig
from patterns.singleton import Singleton
from utils.chdkptpPT import ChdkptpPT
from utils.camera.impl.chdkptpPT import ChdkptpPT
from jpegtran import JPEGImage


Expand Down Expand Up @@ -46,6 +46,7 @@ def take_pictures(self):
try:
self.rotate_photos(pic_names[0], pic_names[1])
except:
print("Exception while rotating pictures.")
return -1
return pic_names

Expand All @@ -69,7 +70,7 @@ def rotate_photos(self, p_left_photo, p_right_photo):
except:
print('Pictures not found yet')
time.sleep(0.5)
if tries > 5:
if tries > 20:
raise Exception
tries += 1

Expand Down
10 changes: 0 additions & 10 deletions src/services/utils/pdfBeads.py

This file was deleted.

29 changes: 0 additions & 29 deletions src/services/utils/scantailor.py

This file was deleted.

18 changes: 0 additions & 18 deletions src/services/utils/taskManager.py

This file was deleted.

15 changes: 0 additions & 15 deletions src/services/utils/tesseract.py

This file was deleted.

1 change: 0 additions & 1 deletion src/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

Empty file added src/utils/camera/__init__.py
Empty file.
File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import subprocess
from subprocess import call
from model.camera import Camera
from utils.cameraDriver import CameraDriver


class Chdkptp:
class Chdkptp(CameraDriver):

# chdk_path to CHDKPTP
global chdk_path
Expand Down
18 changes: 6 additions & 12 deletions src/utils/chdkptpPT.py → src/utils/camera/impl/chdkptpPT.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import re
from subprocess import check_output
from time import sleep

from pexpect import spawn as shell

from utils.cameraDriver import CameraDriver
from utils.camera.cameraDriver import CameraDriver


class ChdkptpPT(CameraDriver):
Expand All @@ -19,7 +17,7 @@ def detect(self):
def prepare(self, p_cam_config):
zoom = p_cam_config.zoom
self.rec_mode()
self.set_quality()
# self.set_quality()
self.set_zoom(zoom)
self.calibrate()

Expand Down Expand Up @@ -57,9 +55,9 @@ def devices_list(self):

def rec_mode(self):
self._execute('rec')
print("Se puso en rec")

def shoot(self, p_save_path, p_pic_names):
# remoteshoot /home/user/lsp00001 -tv=1/25 -sv=80
cams = self.cams
cams['right'].sendline('remoteshoot {0}{1} -tv=1/25 -sv={2}'.format(p_save_path, p_pic_names[0], str(80)))
cams['left'].sendline('remoteshoot {0}{1} -tv=1/25 -sv={2}'.format(p_save_path, p_pic_names[1], str(80)))
Expand All @@ -79,11 +77,10 @@ def connect(self, p_cam_info):
cam.sendline('download orientation.txt /tmp/')
cam.expect('A/.*', timeout=5)

print(cam.after.decode())

orientation = check_output('cat /tmp/orientation.txt', shell=True).decode()
orientation = check_output('cat /tmp/orientation.txt', shell=True).decode().strip()
self.cams[orientation] = cam

# Figure out why is affecting a2200
def set_quality(self):
cams = self.cams
command = ("luar props=require('propcase'); "
Expand All @@ -99,15 +96,12 @@ def set_quality(self):
def _cameras_wait(self):
cams = self.cams
for cam in cams:
cams[cam].expect('con .*> ', timeout=5)
cams[cam].expect('con .*> ', timeout=10)

def _execute(self, command):
cams = self.cams
if not cams:
print ('excepcion')
raise Exception

print ('sigue')
for cam in cams:
cams[cam].sendline(command)
self._cameras_wait()
Empty file added src/utils/output/__init__.py
Empty file.
Empty file.
4 changes: 1 addition & 3 deletions src/utils/pdfBeads.py → src/utils/output/impl/pdfBeads.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os
import subprocess

from utils.outputMaker import OutputMaker
from utils.output.outputMaker import OutputMaker


class PDFBeads(OutputMaker):
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions src/utils/outputMaker.py

This file was deleted.

8 changes: 0 additions & 8 deletions src/utils/task.py

This file was deleted.

Empty file added src/utils/task/__init__.py
Empty file.
Empty file added src/utils/task/impl/__init__.py
Empty file.
Loading

0 comments on commit 387309b

Please sign in to comment.