else:
logging.info('v4l-utils not installed')
-
+
+def make_media_folders():
+ import config
+
+ config.get_main() # just to have main config already loaded
+
+ camera_ids = config.get_camera_ids()
+ for camera_id in camera_ids:
+ camera_config = config.get_camera(camera_id)
+ if not os.path.exists(camera_config['target_dir']):
+ try:
+ os.makedirs(camera_config['target_dir'])
+
+ except Exception as e:
+ logging.error('failed to create root media folder "%s" for camera with id %s: %s' % (
+ camera_config['target_dir'], camera_id, e))
+
+
def start_motion():
import config
import motionctl
logging.info('hello! this is motionEye server %s' % motioneye.VERSION)
test_requirements()
+ make_media_folders()
if settings.SMB_SHARES:
stop, start = smbctl.update_mounts() # @UnusedVariable
def save(self):
services = _load()
- camera_services = services.get(self.camera_id, {})
+ camera_services = services.setdefault(self.camera_id, {})
camera_services[self.NAME] = self
_save(services)
self._folder_id = None
UploadService.__init__(self, camera_id)
-
+
def get_authorize_url(self):
query = {
'scope': self.SCOPE,
return str(e)
def upload_data(self, filename, mime_type, data):
+ filename = os.path.basename(filename)
+
metadata = {
'title': filename,
'parents': [{'id': self._get_folder_id()}]
MAX_FILE_SIZE = 128 * 1024 * 1024 # 128 MB
- def __init__(self, camera_id, location=None, subfolders=True, authorization_key=None, credentials=None, **kwargs):
+ def __init__(self, camera_id, location=None, authorization_key=None, credentials=None, **kwargs):
self._location = location
- self._subfolders = subfolders
self._authorization_key = authorization_key
self._credentials = credentials
def dump(self):
return {
'location': self._location,
- 'subfolders': self._subfolders,
'credentials': self._credentials,
'authorization_key': self._authorization_key
}
def load(self, data):
if 'location' in data:
self._location = data['location']
- if 'subfolders' in data:
- self._subfolders = data['subfolders']
if 'credentials' in data:
self._credentials = data['credentials']
if 'authorization_key' in data: