def take_a_photo(self, save_path, file_name=None): if save_path is None or len(save_path) == 0: ERROR("save path is invaild") return None mkdir_p(save_path) if not save_path.endswith("/"): save_path += "/" if file_name is None or len(file_name) == 0: file_name = time.strftime("%Y_%m_%d_%H%M%S") + ".jpg" file_path = save_path + file_name INFO("taking photo...") subprocess.call([ "fswebcam", # "-d", "/dev/video0", "-r", "1280*720", # "--no-banner", file_path ]) # subprocess.call([ # "wget", # "-O", # file_path, # "http://192.168.1.100:8080/?action=snapshot" # ]) if not os.path.isfile(file_path): INFO("snapshot faild. no such file:" + file_path) return None, None INFO("save orginal photo:" + file_name) size = 320, 240 t_name = self._get_thumbnail_file_name(file_name) im = Image.open(file_path) im.thumbnail(size, Image.ANTIALIAS) im.save(save_path + t_name, "JPEG") INFO("save thumbnail photo:" + t_name) return file_name, t_name
def take_a_photo(self, save_path, file_name=None): if save_path is None or len(save_path) == 0: ERROR("save path is invaild") return None mkdir_p(save_path) if not save_path.endswith("/"): save_path += "/" if file_name is None or len(file_name) == 0: file_name = time.strftime("%Y_%m_%d_%H%M%S") + ".jpg" file_path = save_path + file_name INFO("taking photo...") subprocess.call([ "fswebcam", # "-d", "/dev/video0", "-r", "1280*720", # "--no-banner", file_path ]) # subprocess.call([ # "wget", # "-O", # file_path, # "http://192.168.1.100:8080/?action=snapshot" # ]) if not os.path.isfile(file_path) : INFO("snapshot faild. no such file:" + file_path) return None, None INFO("save orginal photo:" + file_name) size = 320, 240 t_name = self._get_thumbnail_file_name(file_name) im = Image.open(file_path) im.thumbnail(size, Image.ANTIALIAS) im.save(save_path + t_name, "JPEG") INFO("save thumbnail photo:" + t_name) return file_name, t_name
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import inspect import traceback import logging import logging.handlers import config from util.Util import mkdir_p mkdir_p("log") tmpfd_path = config.TMPFS_PATH + "log" mkdir_p(tmpfd_path) if os.path.isdir(tmpfd_path): file_name = os.path.join(tmpfd_path, 'home_debug.log') else: file_name = 'log/debug_home.log' debug_logger = logging.getLogger('DebugLog') handler = logging.handlers.RotatingFileHandler(file_name, maxBytes=50*1024*1024) formatter = logging.Formatter("%(asctime)s - [%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s") handler.setFormatter(formatter) debug_logger.setLevel(logging.DEBUG) debug_logger.addHandler(handler)
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import inspect import traceback import logging import logging.handlers import config from util.Util import mkdir_p mkdir_p("log") tmpfd_path = config.TMPFS_PATH + "log" mkdir_p(tmpfd_path) if os.path.isdir(tmpfd_path): file_name = os.path.join(tmpfd_path, 'home_debug.log') else: file_name = 'log/debug_home.log' debug_logger = logging.getLogger('DebugLog') handler = logging.handlers.RotatingFileHandler(file_name, maxBytes=50 * 1024 * 1024) formatter = logging.Formatter( "%(asctime)s - [%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s") handler.setFormatter(formatter)
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import inspect import traceback import logging import logging.handlers import config from util.Util import mkdir_p mkdir_p("log") file_name = 'log/home_debug.log' debug_logger = logging.getLogger('DebugLog') handler = logging.handlers.RotatingFileHandler(file_name, maxBytes=50*1024*1024) formatter = logging.Formatter("%(asctime)s - [%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s") handler.setFormatter(formatter) debug_logger.setLevel(logging.DEBUG) debug_logger.addHandler(handler) debug_logger.propagate = False # now if you use logger it will not log to console. if config.DEBUG_ENABLE is False: debug_logger.setLevel(logging.CRITICAL) comm_name = 'log/home.log' comm_logger = logging.getLogger('CommonLog')