def update_and_restart(tempdir): import wx updater = os.path.join(os.getcwd(), "mac_updater.pyc") from Authorization import Authorization, kAuthorizationFlagDestroyRights auth = Authorization(destroyflags=(kAuthorizationFlagDestroyRights, )) try: python = sys.executable pipe = auth.executeWithPrivileges(python, updater, tempdir) output = pipe.read() if output.find("error") != -1: wx.MessageBox( _("Error while updating Digsby. Please restart and try again, or grab the latest version from digsby.com. Digsby will now shut down." )) pipe.close() wx.GetApp().ExitMainLoop() return pipe.close() wx.MessageBox(_("Updated successfully. Digsby now needs to restart.")) os.spawnv(os.P_NOWAIT, python, ["python", updater, "restart"]) wx.GetApp().ExitMainLoop() except: wx.MessageBox( _("Unable to authenticate. Please restart and try again."))
def init(self): self = super(MNPPController, self).initWithWindowNibName_("MainMenu") if self: self.path = "/Applications/MNPP/init/" self.auth = Authorization() return self
def updateUser(): dao = PersonDAO() if not Authorization().authorized(request.headers): return unauthorized content = request.get_json() user = dao.updatePerson(content["id"], content["education"], content["experience"]) return jsonify(user.serialize())
def createReferral(): dao = ReferralDAO() if not Authorization().authorized(request.headers): return unauthorized content = request.get_json() result = dao.createReferral( ReferralDTO(-1, content['sender'], "", content['recipient'], "", -1, content['status'])) return jsonify(result.serialize())
def init(self): self = super(MNPPController, self).initWithWindowNibName_("MainMenu") self.phpVersion = "" if self: self.path = "/Applications/MNPP/init/" self.auth = Authorization( destroyflags=(kAuthorizationFlagDestroyRights, )) self.appDelegate = NSApp.delegate() return self
def handle(self): srvIface = Authorization(self.server.users, self._set_authenticated_user) self.transport.start_server(server=srvIface) # Get the session channel chan = self.transport.accept(self.auth_timeout) if chan is None: raise ProtocolError( "session channel not opened (authentication failure?)") self.transport.join()
def updateReferral(): dao = ReferralDAO() if not Authorization().authorized(request.headers): return unauthorized content = request.get_json() result = dao.updateReferral( ReferralDTO(content['id'], content['senderId'], "", content['recipientId'], "", content['company'], content['status'])) return jsonify(result.serialize())
def main(): auth = Authorization(destroyflags=(kAuthorizationFlagDestroyRights, )) fd, name = tempfile.mkstemp('.py') os.write(fd, AUTHORIZEDTOOL) os.close(fd) os.chmod(name, 0700) try: pipe = auth.executeWithPrivileges(name) sys.stdout.write(pipe.read()) pipe.close() finally: os.unlink(name)
def handle(self): print('Handling incoming request by thread: %s' % (threading.current_thread().name)) srvIface = Authorization(self.server.users, self._set_authenticated_user) self.transport.start_server(server=srvIface) # Get the session channel chan = self.transport.accept(self.auth_timeout) if chan is None: raise ProtocolError( "session channel not opened (authentication failure?)") self.transport.join()
def do_it(scripts, links): import os, tempfile, traceback from Authorization import Authorization, kAuthorizationFlagDestroyRights r1, r2 = DEST_PATH, links bad = False for s, l in zip(scripts, links): if os.path.exists(l) and os.path.exists(os.path.realpath(l)): continue bad = True break if bad: ph, pp = os.environ.get('PYTHONHOME', None), os.environ.get('PYTHONPATH', None) auth = Authorization(destroyflags=(kAuthorizationFlagDestroyRights, )) fd, name = tempfile.mkstemp('.py') os.write(fd, AUTHTOOL % (repr(scripts), repr(links))) os.close(fd) os.chmod(name, 0700) try: if pp: del os.environ['PYTHONPATH'] if ph: del os.environ['PYTHONHOME'] pipe = auth.executeWithPrivileges(name) try: sys.stdout.write(pipe.read()) except: sys.stdout.write(pipe.read()) # Probably EINTR pipe.close() except: r1, r2 = None, traceback.format_exc() finally: os.unlink(name) if pp: os.environ['PYTHONPATH'] = pp if ph: os.environ['PYTHONHOME'] = ph return r1, r2
def __init__(self, database): self.authorization = Authorization() self.database = database
также можно перегрузить verification_params для проверки параметров на корректность потом вставить получившееся обьект класса в соотвествующий словарь api_methods_get["TestReq"] = TestReq() """ api_methods_get, api_methods_post = {}, {} api_methods_get["GetResult"] = GetResult() api_methods_get["GetAddresse"] = GetAddresse() api_methods_get["GetRoute"] = GetRoute() api_methods_get["GetSegment"] = GetSegment() api_methods_get["SetSegment"] = SetSegment() api_methods_get["getAllWayPoints"] = GetAllWayPoints() api_methods_get["addNewPoint"] = AddNewPoint() api_methods_get["Authorization"] = Authorization() api_methods_get["addNewLink"] = AddNewLink() api_methods_get["getAllWaySegments"] = GetAllWaySegments() api_methods_get["Registration"] = Registration() class HttpServer(BaseHTTPRequestHandler): def _set_headers(self): self.send_response(200) self.send_header('Content-type', 'text/plain') self.send_header('Access-Control-Allow-Origin', '*') self.end_headers() def do_GET(self): self._set_headers() url = self.requestline[9:-9]
def getReferrals(userId): dao = ReferralDAO() if not Authorization().authorized(request.headers): return unauthorized referrals = dao.getReferrals(userId) return jsonify([x.serialize() for x in referrals])
def filter(): dao = PersonDAO() if not Authorization().authorized(request.headers): return unauthorized filtered = dao.filter(request.get_json()) return jsonify([x.serialize() for x in filtered])
def getUser(identifier=None): dao = PersonDAO() if not Authorization().authorized(request.headers): return unauthorized user = dao.getPerson(identifier) return jsonify(user.serialize())