Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion etc/eyefiserver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ geotag_accuracy:140000
# /home/myblog/pictures/%%Y-%%m-%%d
# notice the double percent sign to escape % from ini interpolation

upload_dir:/home/david/Pictures/eye-fi/%%Y-%%m
upload_dirs_0:/home/david/Pictures/eye-fi/%%Y-%%m
upload_dirs_1:/home/david/Pictures/eye-fi/%%Y-%%m

# The UID of the user that you want to own the uploaded images (if commented out, ownership of files will not be changed)
upload_uid:0
Expand Down
38 changes: 35 additions & 3 deletions usr/local/bin/eyefiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,10 @@ def stop(self):
message = "pidfile %s does not exist. Daemon not running?\n"
sys.stderr.write(message % self.pidfile)
return 1

# Try killing the daemon process
try:
while 1:
os.kill(pid, SIGTERM)
os.kill(pid, 9)
time.sleep(0.1)
except OSError, err:
err = str(err)
Expand Down Expand Up @@ -678,7 +677,10 @@ def uploadPhoto(self,postData):
timeoffset = time.timezone
timezone = timeoffset / 60 / 60 * -1
imageDate = datetime.fromtimestamp(member.mtime) - timedelta(hours=timezone)
uploadDir = imageDate.strftime(self.server.config.get('EyeFiServer','upload_dir'))

mac_to_uploaddir_map = self._get_mac_uploaddir_dict()
mac = handler.extractedElements["macaddress"]
uploadDir = imageDate.strftime(mac_to_uploaddir_map[mac])
eyeFiLogger.debug("Creating folder " + uploadDir)
if not os.path.isdir(uploadDir):
os.makedirs(uploadDir)
Expand Down Expand Up @@ -856,6 +858,36 @@ def getPhotoStatus(self,postData):

return doc.toxml(encoding="UTF-8")

def _get_mac_uploaddir_dict(self):
macs = {}
upload_dirs = {}
uploadDir = ""
try:
uploadDir = self.server.config.get('EyeFiServer','upload_dir')
except:
uploadDir = ""
for key, value in self.server.config.items('EyeFiServer'):
try:
if key.find('upload_dirs_') == 0:
index = int(key[12:])
upload_dirs[index] = value
elif key.find('mac_') == 0:
index = int(key[4:])
macs[index] = value
except:
eyeFiLogger.info( "upload_dirs not defined, hopefully upload_dir is: ")
d = {}
for key in macs.keys():
if len(upload_dirs) == 0 and len(uploadDir) == 0:
eyeFiLogger.error( "Neither upload_dir or upload_dirs_0 are defined in the config file, you must define one or the other")
system.exit(1)
if len(upload_dirs) != 0:
d[macs[key]] = upload_dirs[key]
else:
d[macs[key]] = uploadDir

return d

def _get_mac_uploadkey_dict(self):
macs = {}
upload_keys = {}
Expand Down