Moved static methods to functions
This commit is contained in:
parent
323c48858d
commit
cb122e5ef6
1 changed files with 15 additions and 16 deletions
|
|
@ -79,6 +79,18 @@ class CameraEvent(object):
|
||||||
self.events[get_ident()][0].clear()
|
self.events[get_ident()][0].clear()
|
||||||
|
|
||||||
|
|
||||||
|
def generate_basename(obj_list: list) -> str:
|
||||||
|
initial_basename = generate_basename()
|
||||||
|
basename = initial_basename
|
||||||
|
# Handle clashing
|
||||||
|
iterator = 1
|
||||||
|
while basename in [obj.basename for obj in obj_list]:
|
||||||
|
basename = initial_basename + "_{}".format(iterator)
|
||||||
|
iterator += 1
|
||||||
|
|
||||||
|
return basename
|
||||||
|
|
||||||
|
|
||||||
class BaseCamera(object):
|
class BaseCamera(object):
|
||||||
"""
|
"""
|
||||||
Base implementation of StreamingCamera.
|
Base implementation of StreamingCamera.
|
||||||
|
|
@ -97,7 +109,7 @@ class BaseCamera(object):
|
||||||
self.stream_timeout_enabled = True #: bool: Enable or disable timing out the stream
|
self.stream_timeout_enabled = True #: bool: Enable or disable timing out the stream
|
||||||
|
|
||||||
self.state = {} #: dict: Dictionary for capture state
|
self.state = {} #: dict: Dictionary for capture state
|
||||||
self._config = {} #: dict: Dictionary of base camera config
|
self.config = {} #: dict: Dictionary of base camera config
|
||||||
self.paths = {
|
self.paths = {
|
||||||
'image': BASE_CAPTURE_PATH,
|
'image': BASE_CAPTURE_PATH,
|
||||||
'video': BASE_CAPTURE_PATH,
|
'video': BASE_CAPTURE_PATH,
|
||||||
|
|
@ -283,7 +295,7 @@ class BaseCamera(object):
|
||||||
|
|
||||||
# Generate file name
|
# Generate file name
|
||||||
if not filename:
|
if not filename:
|
||||||
filename = self.generate_basename(self.images)
|
filename = generate_basename(self.images)
|
||||||
logging.debug(filename)
|
logging.debug(filename)
|
||||||
|
|
||||||
# Create capture object
|
# Create capture object
|
||||||
|
|
@ -323,7 +335,7 @@ class BaseCamera(object):
|
||||||
|
|
||||||
# Generate file name
|
# Generate file name
|
||||||
if not filename:
|
if not filename:
|
||||||
filename = self.generate_basename(self.videos)
|
filename = generate_basename(self.videos)
|
||||||
logging.debug(filename)
|
logging.debug(filename)
|
||||||
|
|
||||||
# Create capture object
|
# Create capture object
|
||||||
|
|
@ -343,19 +355,6 @@ class BaseCamera(object):
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
# INTELLIGENTLY GENERATE FILENAMES
|
|
||||||
|
|
||||||
def generate_basename(self, obj_list: list) -> str:
|
|
||||||
initial_basename = generate_basename()
|
|
||||||
basename = initial_basename
|
|
||||||
# Handle clashing
|
|
||||||
iterator = 1
|
|
||||||
while basename in [obj.basename for obj in obj_list]:
|
|
||||||
basename = initial_basename + "_{}".format(iterator)
|
|
||||||
iterator += 1
|
|
||||||
|
|
||||||
return basename
|
|
||||||
|
|
||||||
# WORKER THREAD
|
# WORKER THREAD
|
||||||
|
|
||||||
def _thread(self):
|
def _thread(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue