当前位置: 首页>>代码示例>>Python>>正文


Python Settings.getWebprintFolder方法代码示例

本文整理汇总了Python中settings.Settings.getWebprintFolder方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getWebprintFolder方法的具体用法?Python Settings.getWebprintFolder怎么用?Python Settings.getWebprintFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在settings.Settings的用法示例。


在下文中一共展示了Settings.getWebprintFolder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: move_webprint_dir

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getWebprintFolder [as 别名]
    def move_webprint_dir(self, dest):
        """Moves the webprint folder to a new location.

        Destination folder should not exist.
        If it does exist, it should be empty.

        If the webprint folder does not exist, creates it.
        Folder watching is temporarily stopped during this operation.
        """
        dest = str(dest)
        settings = Settings()
        webprint_dir = settings.getWebprintFolder()
        if os.path.exists(dest):
            #TODO: Handel errors on this delete
            shutil.rmtree(dest)
        os.mkdir(dest)
        if os.path.exists(webprint_dir):
            self.stop_watching()
            for f in os.listdir(webprint_dir):
                #TODO: Handel errors here
                shutil.move(os.path.join(webprint_dir, f), dest)
            os.rmdir(webprint_dir)
            settings.setWebprintFolder(dest)
            self.start_watching()
        else:
            #webprint folder does not exist
            settings.setWebprintFolder(dest)
            self.build_webprint_dir()
开发者ID:fgsoap,项目名称:WebPrint-Tray-Icon,代码行数:30,代码来源:watchfolder.py

示例2: start_watching

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getWebprintFolder [as 别名]
    def start_watching(self):
        """Starts folder watching.

        Loads folders to watch from settings.
        """
        settings = Settings()
        webprint_dir = str(settings.getWebprintFolder())
        for (name, location) in settings.getInstalledPrinters():
            path = os.path.join(webprint_dir, str(location))
            self.observer.schedule(self.event_handler, path)
开发者ID:fgsoap,项目名称:WebPrint-Tray-Icon,代码行数:12,代码来源:watchfolder.py

示例3: __init__

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getWebprintFolder [as 别名]
 def __init__(self, parent=None):
     super(FolderWatcher, self).__init__(parent)
     settings = Settings()
     self.event_handler = _NewFileEventHandler()
     self.event_handler.addJob.connect(self.addJob)
     if not os.path.exists(settings.getWebprintFolder()):
         self.build_webprint_dir()
     self.observer = Observer()
     self.observer.start()
     self.start_watching()
开发者ID:fgsoap,项目名称:WebPrint-Tray-Icon,代码行数:12,代码来源:watchfolder.py

示例4: build_webprint_dir

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getWebprintFolder [as 别名]
    def build_webprint_dir(self):
        """Create print folders in the 'webprint' directory.

        Delete files and folders not listed in settings.
        Creates the webprint directory if it does not exist.
        Folder watching is temporarily stopped during this operation.
        """
        self.stop_watching()
        settings = Settings()
        webprint_dir = settings.getWebprintFolder()
        if not os.path.exists(webprint_dir):
            os.makedirs(webprint_dir)
        folders = [location for (name, location) in
                    settings.getInstalledPrinters()]
        ls = os.listdir(webprint_dir)
        for folder in folders:
            if folder not in ls:
                os.mkdir(os.path.join(webprint_dir, folder))
            else:
                ls.remove(folder)
        for item in ls:
            shutil.rmtree(os.path.join(webprint_dir, item))
        self.start_watching()
开发者ID:fgsoap,项目名称:WebPrint-Tray-Icon,代码行数:25,代码来源:watchfolder.py


注:本文中的settings.Settings.getWebprintFolder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。