def fetch(self): if self.enabled: token = AppStorage("accessToken").retrieve() response = Ghostlines('v1', token=token).applicant_roster(self.family_id) self.applicant_roster = response.json() self.set(self.applicant_roster["applicants"])
def fetch(self): if self.font.lib.has_key('pm.ghostlines.ghostlines.registry_token'): response = Ghostlines('v0.1').registry(self.font.lib['pm.ghostlines.ghostlines.registry_token']) registry = response.json() applicant_emails = [r['email_address'] for r in registry['applicants'] if not r['approved_at']] self.list.set(applicant_emails)
def send(self, sender): recipients = self.window.recipients.get() selection = [ recipients[i] for i in self.window.recipients.getSelection() ] if selection == []: selection = self.window.recipients.get() recipients = ', '.join(selection) progress = ProgressWindow('', tickCount=3, parentWindow=self.window) try: tmpdir = tempfile.mkdtemp(prefix="ghostlines") progress.update('Generating OTF') # Should be controlled which options are used somewhere filename = os.path.join(tmpdir, self.font.info.familyName + '.otf') self.font.generate(format="otf", path=filename, decompose=True, checkOutlines=True, autohint=True) progress.update('Sending via Ghostlines') with open(filename, 'rb') as otf: params = dict(otf=otf, recipients=recipients, notes=self.window.notes_field.get(), designer_email_address=self.window. email_address_field.get()) license_path = self.license_storage.retrieve() if license_path is not '' and os.path.exists(license_path): with open(license_path, 'rb') as license: filename = os.path.basename(license_path) _, extension = os.path.splitext(license_path) content_type = filetypes[extension] params['license'] = (filename, license, content_type) response = Ghostlines('v0.1').send(**params) else: response = Ghostlines('v0.1').send(**params) if response.status_code == requests.codes.created: message("{} was delivered".format(self.font.info.familyName)) else: print repr(response) message( "{} could not be delivered".format( self.font.info.familyName), "Error code: {}\n{}".format(response.status_code, response.json())) finally: progress.close()
def send(self, *_): subscribers = self.window.subscriber_info.subscribers.get() subscriber_ids = [ subscribers[i]["id"] for i in self.window.subscriber_info.subscribers.getSelection() ] notes = self.note_draft_storage.retrieve() font_family_id = self.family_id_storage.retrieve() license_path = self.license_storage.retrieve() progress = ProgressWindow('', tickCount=3, parentWindow=self.window) try: tmpdir = tempfile.mkdtemp(prefix="ghostlines") progress.update('Generating OTF') # Should be controlled which options are used somewhere otf_path = os.path.join(tmpdir, '{}.otf'.format(self.font.info.familyName)) self.font.generate(format="otf", path=otf_path, decompose=True, checkOutlines=True, autohint=True) progress.update('Sending via Ghostlines') params = dict(notes=notes, font_family_id=font_family_id) with open(otf_path, 'rb') as otf: params['otfs'] = [(os.path.basename(otf_path), otf.read(), "application/octet-stream")] if subscriber_ids: params['subscriber_ids[]'] = subscriber_ids if self.license_exists: with open(license_path, 'rb') as license: filename = os.path.basename(license_path) _, extension = os.path.splitext(license_path) content_type = filetypes[extension] params['license'] = (filename, license.read(), content_type) token = AppStorage("accessToken").retrieve() response = Ghostlines('v1', token=token).create_release(**params) if response.status_code == requests.codes.created: message("{} was delivered".format(self.font.info.familyName)) self.refresh_releases() else: ErrorMessage( "{} could not be delivered".format( self.font.info.familyName), response.json()["errors"]) finally: progress.close()
def activate(self, *args): response = Ghostlines('v0.1').enable_applicants({ 'font_name': self.font.info.familyName, 'designer': self.font.info.designer }) registry = response.json() self.font.lib['pm.ghostlines.ghostlines.registry_token'] = registry['token'] self.activated = True
def enable(self, *args): token = AppStorage("accessToken").retrieve() response = Ghostlines('v1', token=token).enable_applicants_v1(self.family_id) json = response.json() if response.status_code == 201: self.applicant_roster = json self.enabled = True else: ErrorMessage("Could not enable applicants", json["errors"]).open()
def fetch(self): if self.font.lib.has_key('pm.ghostlines.ghostlines.registry_token'): response = Ghostlines('v0.1').registry( self.font.lib['pm.ghostlines.ghostlines.registry_token']) registry = response.json() applicant_emails = [ r['email_address'] for r in registry['applicants'] if not r['approved_at'] ] self.list.set(applicant_emails)
def activate(self, *args): response = Ghostlines('v0.1').enable_applicants({ 'font_name': self.font.info.familyName, 'designer': self.font.info.openTypeNameDesigner }) registry = response.json() self.font.lib['pm.ghostlines.ghostlines.registry_token'] = registry[ 'token'] self.activated = True
def sign_in(self, _): email_address = self.window.email_field.get() password = self.window.password_field.get() response = Ghostlines('v1').authenticate(email_address, password) json = response.json() if response.status_code == 201: # Success! account = json['account'] token = json['token'] AppStorage('accessToken').store(token) self.success_window(self.__class__, account=account).open() self.window.close() else: ErrorMessage('Sign In Error', json['errors']).open()
def send(self, sender): recipients = ', '.join(self.window.recipients.get()) progress = ProgressWindow('', tickCount=3, parentWindow=self.window) try: tmpdir = tempfile.mkdtemp(prefix="ghostlines") progress.update('Generating OTF') # Should be controlled which options are used somewhere filename = os.path.join(tmpdir, self.font.info.familyName + '.otf') self.font.generate(filename, "otf", decompose=True, checkOutlines=True, autohint=True) progress.update('Sending via Ghostlines') with open(filename, 'rb') as otf: params = dict( otf=otf, recipients=recipients, notes=self.window.notes_field.get(), designer_email_address=self.window.email_address_field.get() ) license_path = self.license_storage.retrieve() if license_path is not '' and os.path.exists(license_path): with open(license_path, 'rb') as license: filename = os.path.basename(license_path) _, extension = os.path.splitext(license_path) content_type = filetypes[extension] params['license'] = (filename, license, content_type) response = Ghostlines('v0.1').send(**params) else: response = Ghostlines('v0.1').send(**params) if response.status_code == requests.codes.created: message("{} was delivered".format(self.font.info.familyName)) else: print repr(response) message("{} could not be delivered".format(self.font.info.familyName), "Error code: {}\n{}".format(response.status_code, response.json())) finally: progress.close()
def open_registration_page(self, *args): response = Ghostlines('v0.1').registry(self.font.lib['pm.ghostlines.ghostlines.registry_token']) registry = response.json() webbrowser.open(registry['url'])
def account(self): token = AppStorage('accessToken').retrieve() response = Ghostlines("v1", token=token).account() return response.json()
def open_registration_page(self, *args): response = Ghostlines('v0.1').registry( self.font.lib['pm.ghostlines.ghostlines.registry_token']) registry = response.json() webbrowser.open(registry['url'])