Exemplo n.º 1
0
  def scan(self):    
    global logger
    
    self.error = None
    
    try:
      self.check_open_app()
      self.check_pyzipista()
      
      if self.tool_sync_config.webdav.username:
        username = self.tool_sync_config.webdav.username
        password = self.tool_sync_config.webdav.password
        
        logger.debug('Open WebDAV connection to host %s on port %d for user %s and auth mode %s' % (self.tool_sync_config.webdav.server, self.tool_sync_config.webdav.port, username, self.tool_sync_config.webdav.auth_mode))
        if password == sync_config.PASSWORD_USE_KEY_CHAIN:
          password = util.get_password_from_keychain(self.get_webdav_service_name(), username)

        webdav_client = client.Client(self.tool_sync_config.webdav.server,
                             port=self.tool_sync_config.webdav.port,
                             protocol='http', verify_ssl=False, cert=None, 
                             username=username, password=password,
                             auth_mode=self.tool_sync_config.webdav.auth_mode)
      else:
        logger.debug('Open non-autheticated WebDAV connection to host %s on port %d' % (self.tool_sync_config.webdav.server, self.tool_sync_config.webdav.port))
        webdav_client = client.Client(self.tool_sync_config.webdav.server,
                             port=self.tool_sync_config.webdav.port,
                             protocol='http', verify_ssl=False, cert=None)
                           
      local_file_access = FileAccess(self.tool_sync_config.repository.local_path)
      remote_file_access = WebDavFileAccess(webdav_client, self.tool_sync_config.repository.remote_path, self.tool_sync_config.webdav)      
      self.compare_info = CompareInfo(local_file_access, remote_file_access)
  
      logger.debug("Local files:")
      dump_files(self.compare_info.local_files)
      logger.debug("Remote files:")
      dump_files(self.compare_info.remote_files)
  
      logger.debug("Local new files:")
      for file in self.compare_info.local_change_info.new_files:
        logger.debug("    %s" % str(file))
      logger.debug("Local modified files:")
      for file in self.compare_info.local_change_info.modified_files:
        logger.debug("    %s" % str(file))
      logger.debug("Remote new files:")
      for file in self.compare_info.remote_change_info.new_files:
        logger.debug("    %s" % str(file))
      logger.debug("Remote modified files:")
      for file in self.compare_info.remote_change_info.modified_files:
        logger.debug("    %s" % str(file))

    except Exception as e:
      error_text = str(e)
      logger.error("Error during scan: %s" % error_text)
      self.interpret_error(error_text)
      self.error = error_text
Exemplo n.º 2
0
 def __init__(self):
   super(WorkingCopySupport, self).__init__('working-copy')
   self.key = util.get_password_from_keychain(KEYCHAIN_SERVICE, KEYCHAIN_ACCOUNT)