def __init__(self, site, domain=None, templates=None, progression=False, email=None, password=None): """ Creates a new Site Controller Args: site: the webspace name of your site (e.g. mySite) domain: domain of your Google Apps hosted domain (e.g. example.com) templates: path to the directory with template files progression: if True, print progress of the mirroring process email: the user's email address or username password: the password for the user's account """ if domain: self.client = gdata.sites.client.SitesClient(source=SOURCE, site=site, domain=domain) else: self.client = gdata.sites.client.SitesClient(source=SOURCE, site=site) self.progression = progression if templates: self.templates_path = templates else: self.templates_path = DEFAULT_TEMPLATES if password: self.client.client_login(email=email, password=password, source=self.client.source) self.etag_new = ETagDocument() self.etag_old = None self.landing_page = None
def process_modification_doc(self, path, directory): """ The method serves for checking whether or not the site has been mirrored before (ie. there is a file etags.xml at the path path/directory/ that contatins information about the last mirroring). In case this is the first mirroring of the site, the class attribute etag_old is set to None, which means that the mirroring process will crates a directory hierarchy and save all the current content of the site to the disk. In case the site has been mirrored before (to the same path), information about the last mirroring are set to etag_old (from path/directory/etags.xml), which means that the mirroring process will continue only if there has been some changes since the last time and will download and save only new or modified attachments. Args: path: path where is (will be) the root directory (e.g. /home/me/sites/) directory: name of the root directory where the site is to be saved (e.g. my_site) """ path_to_etags = path + directory + '/' + ETAGS_DOC if os.access(path_to_etags, os.F_OK): self.etag_old = ETagDocument() self.etag_old.get_document(path_to_etags) self.etag_new.create()