def post(self): user_data = UserData.current() if not user_data: return if user_data.is_child_account(): self.render_json({"error": "You cannot vote yet."}) return vote_type = self.request_int( "vote_type", default=discussion_models.FeedbackVote.ABSTAIN) if (vote_type == discussion_models.FeedbackVote.UP and not Privileges.can_up_vote(user_data)): self.render_json({ "error": Privileges.need_points_desc(Privileges.UP_VOTE_THRESHOLD, "up vote") }) return elif (vote_type == discussion_models.FeedbackVote.DOWN and not Privileges.can_down_vote(user_data)): self.render_json({ "error": Privileges.need_points_desc(Privileges.DOWN_VOTE_THRESHOLD, "down vote") }) return entity_key = self.request_string("entity_key", default="") if entity_key: entity = db.get(entity_key) if entity and entity.authored_by(user_data): self.render_json( {"error": "You cannot vote for your own posts."}) return if vote_type != discussion_models.FeedbackVote.ABSTAIN: limiter = VoteRateLimiter(user_data) if not limiter.increment(): self.render_json({"error": limiter.denied_desc()}) return # We kick off a taskqueue item to perform the actual vote insertion # so we don't have to worry about fast writes to the entity group # causing contention problems for the HR datastore, because # the taskqueue will just retry w/ exponential backoff. # TODO(marcia): user_data.email may change. user_id is preferred taskqueue.add(url='/admin/discussion/finishvoteentity', queue_name='voting-queue', params={ "email": user_data.email, "vote_type": self.request_int( "vote_type", default=discussion_models.FeedbackVote.ABSTAIN), "entity_key": entity_key })
class Admin(User): def __init__(self, first_name, last_name): super().__init__(first_name, last_name) self.privileges = Privileges() def show_privilege(self): self.privileges.show_privileges()
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() self.load_xml_description( self.command_args['--root'] ) log.info('Creating system image') if not os.path.exists(self.command_args['--target-dir']): Path.create(self.command_args['--target-dir']) setup = SystemSetup( xml_state=self.xml_state, description_dir=self.command_args['--root'], root_dir=self.command_args['--root'] ) setup.call_image_script() image_builder = ImageBuilder( self.xml_state, self.command_args['--target-dir'], self.command_args['--root'] ) result = image_builder.create() result.print_results() result.dump( self.command_args['--target-dir'] + '/kiwi.result' )
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() self.load_xml_description(self.command_args['--root']) package_requests = False if self.command_args['--add-package']: package_requests = True if self.command_args['--delete-package']: package_requests = True log.info('Updating system') self.system = System(self.xml_state, self.command_args['--root'], allow_existing=True) manager = self.system.setup_repositories() if not package_requests: self.system.update_system(manager) else: if self.command_args['--add-package']: self.system.install_packages( manager, self.command_args['--add-package']) if self.command_args['--delete-package']: self.system.delete_packages( manager, self.command_args['--delete-package'])
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() self.load_xml_description(self.command_args['--description']) if self.command_args['--set-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(self.command_args['--set-repo']) self.xml_state.set_repository(repo_source, repo_type, repo_alias, repo_prio) if self.command_args['--add-repo']: for add_repo in self.command_args['--add-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(add_repo) self.xml_state.add_repository(repo_source, repo_type, repo_alias, repo_prio) if os.path.exists('/.buildenv'): # This build runs inside of a buildservice worker. Therefore # the repo defintions is adapted accordingly self.xml_state.translate_obs_to_suse_repositories() elif self.command_args['--obs-repo-internal']: # This build should use the internal SUSE buildservice # Be aware that the buildhost has to provide access self.xml_state.translate_obs_to_ibs_repositories() log.info('Preparing system') system = System(self.xml_state, self.command_args['--root'], self.command_args['--allow-existing-root']) manager = system.setup_repositories() system.install_bootstrap(manager) system.install_system(manager) profile = Profile(self.xml_state) defaults = Defaults() defaults.to_profile(profile) setup = SystemSetup(self.xml_state, self.command_args['--description'], self.command_args['--root']) setup.import_shell_environment(profile) setup.import_description() setup.import_overlay_files() setup.call_config_script() setup.import_image_identifier() setup.setup_groups() setup.setup_users() setup.setup_keyboard_map() setup.setup_locale() setup.setup_timezone() system.pinch_system(manager)
def post(self): user_data = UserData.current() if not user_data: return if user_data.is_child_account(): self.render_json({"error": "Je kan nog niet stemmen."}) return vote_type = self.request_int( "vote_type", default=discussion_models.FeedbackVote.ABSTAIN) if (vote_type == discussion_models.FeedbackVote.UP and not Privileges.can_up_vote(user_data)): self.render_json({ "error": Privileges.need_points_desc( Privileges.UP_VOTE_THRESHOLD, "up vote") }) return elif (vote_type == discussion_models.FeedbackVote.DOWN and not Privileges.can_down_vote(user_data)): self.render_json({ "error": Privileges.need_points_desc( Privileges.DOWN_VOTE_THRESHOLD, "down vote") }) return entity_key = self.request_string("entity_key", default="") if entity_key: entity = db.get(entity_key) if entity and entity.authored_by(user_data): self.render_json({ "error": "Je kan niet op je eigen opmerking stemmen." }) return if vote_type != discussion_models.FeedbackVote.ABSTAIN: limiter = VoteRateLimiter(user_data) if not limiter.increment(): self.render_json({"error": limiter.denied_desc()}) return # We kick off a taskqueue item to perform the actual vote insertion # so we don't have to worry about fast writes to the entity group # causing contention problems for the HR datastore, because # the taskqueue will just retry w/ exponential backoff. # TODO(marcia): user_data.email may change. user_id is preferred taskqueue.add( url='/admin/discussion/finishvoteentity', queue_name='voting-queue', params={ "email": user_data.email, "vote_type": self.request_int( "vote_type", default=discussion_models.FeedbackVote.ABSTAIN), "entity_key": entity_key } )
def __init__(self, first_name, last_name, birthday, password_hash, security_level, identity_number, privileges): super().__init__(first_name, last_name, birthday, password_hash, security_level, identity_number) self.privileges = Privileges(privileges) self.base_user = User(first_name, last_name, birthday, password_hash, security_level, identity_number)
def __init__(self, first_name, last_name, age): """Initialise attributes of the parent class.""" super().__init__(first_name, last_name, age) #Add attribute privileges, that stores a list of string like: 'can add post'... #Add a function that will list the administrators set of privileges. self.privileges = Privileges()
def __init__( self, first_name, last_name, location, nickname, login_attempt=0): super().__init__(first_name, last_name, location, nickname, login_attempt) self.privileges = Privileges()
def post(self): # You have to be logged in to vote user_data = UserData.current() if not user_data: return vote_type = self.request_int("vote_type", default=FeedbackVote.ABSTAIN) if vote_type == FeedbackVote.UP and not Privileges.can_up_vote(user_data): self.render_json({"error": Privileges.need_points_desc(Privileges.UP_VOTE_THRESHOLD, "up vote")}) return elif vote_type == FeedbackVote.DOWN and not Privileges.can_down_vote(user_data): self.render_json({"error": Privileges.need_points_desc(Privileges.DOWN_VOTE_THRESHOLD, "down vote")}) return entity_key = self.request_string("entity_key", default="") if entity_key: entity = db.get(entity_key) if entity and entity.authored_by(user_data): self.render_json({"error": "You cannot vote for your own posts."}) return if vote_type != FeedbackVote.ABSTAIN: limiter = VoteRateLimiter(user_data) if not limiter.increment(): self.render_json({"error": limiter.denied_desc()}) return # We kick off a taskqueue item to perform the actual vote insertion # so we don't have to worry about fast writes to the entity group # causing contention problems for the HR datastore, because # the taskqueue will just retry w/ exponential backoff. taskqueue.add(url='/admin/discussion/finishvoteentity', queue_name='voting-queue', params={ "email": user_data.email, "vote_type": self.request_int("vote_type", default=FeedbackVote.ABSTAIN), "entity_key": entity_key } )
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() self.load_xml_description( self.command_args['--root'] ) package_requests = False if self.command_args['--add-package']: package_requests = True if self.command_args['--delete-package']: package_requests = True log.info('Updating system') self.system = System( self.xml_state, self.command_args['--root'], allow_existing=True ) manager = self.system.setup_repositories() if not package_requests: self.system.update_system(manager) else: if self.command_args['--add-package']: self.system.install_packages( manager, self.command_args['--add-package'] ) if self.command_args['--delete-package']: self.system.delete_packages( manager, self.command_args['--delete-package'] )
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() self.load_xml_description(self.command_args['--root']) log.info('Creating system image') if not os.path.exists(self.command_args['--target-dir']): Path.create(self.command_args['--target-dir']) setup = SystemSetup(xml_state=self.xml_state, description_dir=self.command_args['--root'], root_dir=self.command_args['--root']) setup.call_image_script() image_builder = ImageBuilder(self.xml_state, self.command_args['--target-dir'], self.command_args['--root']) result = image_builder.create() result.print_results() result.dump(self.command_args['--target-dir'] + '/kiwi.result')
def __init__(self, first_name, last_name, user_name, email, password, privileges, login_attempts=0): """Initializes attributes to describe an Admin user""" super().__init__(first_name, last_name, user_name, email, password, login_attempts=0) self.privileges = Privileges(privileges)
def __init__(self, first_name, last_name, age, phone_number): super().__init__(first_name, last_name, age, phone_number) self.admin_privileges = Privileges()
from privileges import Privileges power = ["doesn't have much to do", 'can sleep tight', 'has to know linux'] power += ['has to have linux installed to be one'] Admin = Privileges(power) Admin.show_privileges()
def __init__(self, first_name, last_name, username, email, location): """Initialize the admin.""" super().__init__(first_name, last_name, username, email, location) # Initialize an empty set of privileges self.privileges = Privileges()
from user import User from privileges import Privileges from admin import Admin priv = ["Can add post", "Can delete post", "Can ban users"] privileges = Privileges(priv) user1 = User("Susie","Green", 25, 50000, "sueZ", "*****@*****.**") user2 = User("Steve","Smith", 34, 75000, "sSmith", "*****@*****.**") user3 = User("Jeff","Goldblum", 65, 130000, "JGold", "*****@*****.**") user4 = User("Dave","Bingham", 32, 40000, "d_bing", "*****@*****.**") admin1 = Admin("Scott","Stevenson", 38, 72000, "s_steven", "*****@*****.**", privileges) user1.greet_user() user2.greet_user() user3.greet_user() user4.greet_user() admin1.greet_user() user1.describe() user2.describe() user3.describe() user4.describe() admin1.describe() privileges.show_privileges()
def __init__(self, first, last, age): super().__init__(first, last, age) self.privileges = Privileges('text message')
def __init__(self, first_name, last_name, age): super().__init__(first_name, last_name, age) self.privileges = Privileges()
##------------------------------- # Cap.9 - Classes # Python Crash Course # Autor: Washington Candeia # Faça você mesmo, p.249 # 9.12 - Vários módulos ##------------------------------- from user import User from privileges import Privileges admi = User('mendoim', 'brown', 8) print(admi.describe_user()) ad = Privileges() ad.show_privileges()
#-*-coding:utf-8-*- from privileges import Privileges dany = Privileges() dany.show_privileges()
def __init__(self, first_name, last_name, age, location, privileges): super().__init__(first_name, last_name, age, location) self.privileges = Privileges(privileges)
#coding=gbk from privileges import Privileges from admin import Admin privileges = ['can add post','can delete post','can ban user']; pri = Privileges(privileges); admin = Admin('guoying','ma','�������������',pri); admin.show_privileges();
def __init__(self, first_name, last_name, email, sex='None'): super().__init__(first_name, last_name, email, sex) self.privileges = Privileges('admin')
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() image_root = self.command_args['--target-dir'] + '/build/image-root' Path.create(image_root) if not self.global_args['--logfile']: log.set_logfile(self.command_args['--target-dir'] + '/build/image-root.log') self.load_xml_description(self.command_args['--description']) if self.command_args['--set-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(self.command_args['--set-repo']) self.xml_state.set_repository(repo_source, repo_type, repo_alias, repo_prio) if self.command_args['--add-repo']: for add_repo in self.command_args['--add-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(add_repo) self.xml_state.add_repository(repo_source, repo_type, repo_alias, repo_prio) Path.create(self.command_args['--target-dir']) if os.path.exists('/.buildenv'): # This build runs inside of a buildservice worker. Therefore # the repo defintions is adapted accordingly self.xml_state.translate_obs_to_suse_repositories() elif self.command_args['--obs-repo-internal']: # This build should use the internal SUSE buildservice # Be aware that the buildhost has to provide access self.xml_state.translate_obs_to_ibs_repositories() log.info('Preparing new root system') system = System(self.xml_state, image_root, True) manager = system.setup_repositories() system.install_bootstrap(manager) system.install_system(manager) profile = Profile(self.xml_state) defaults = Defaults() defaults.to_profile(profile) setup = SystemSetup(self.xml_state, self.command_args['--description'], image_root) setup.import_shell_environment(profile) setup.import_description() setup.import_overlay_files() setup.call_config_script() setup.import_image_identifier() setup.setup_groups() setup.setup_users() setup.setup_keyboard_map() setup.setup_locale() setup.setup_timezone() system.pinch_system(manager) # make sure system instance is cleaned up now del system setup.call_image_script() # make sure setup instance is cleaned up now del setup log.info('Creating system image') image_builder = ImageBuilder(self.xml_state, self.command_args['--target-dir'], image_root) result = image_builder.create() result.print_results() result.dump(self.command_args['--target-dir'] + '/kiwi.result')
def __init__(self, first_name, last_name, privileges): super().__init__(first_name, last_name, 'None', 0) self.privileges = Privileges(privileges)
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() self.load_xml_description( self.command_args['--description'] ) if self.command_args['--set-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(self.command_args['--set-repo']) self.xml_state.set_repository( repo_source, repo_type, repo_alias, repo_prio ) if self.command_args['--add-repo']: for add_repo in self.command_args['--add-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(add_repo) self.xml_state.add_repository( repo_source, repo_type, repo_alias, repo_prio ) if os.path.exists('/.buildenv'): # This build runs inside of a buildservice worker. Therefore # the repo defintions is adapted accordingly self.xml_state.translate_obs_to_suse_repositories() elif self.command_args['--obs-repo-internal']: # This build should use the internal SUSE buildservice # Be aware that the buildhost has to provide access self.xml_state.translate_obs_to_ibs_repositories() log.info('Preparing system') system = System( self.xml_state, self.command_args['--root'], self.command_args['--allow-existing-root'] ) manager = system.setup_repositories() system.install_bootstrap(manager) system.install_system( manager ) profile = Profile(self.xml_state) defaults = Defaults() defaults.to_profile(profile) setup = SystemSetup( self.xml_state, self.command_args['--description'], self.command_args['--root'] ) setup.import_shell_environment(profile) setup.import_description() setup.import_overlay_files() setup.call_config_script() setup.import_image_identifier() setup.setup_groups() setup.setup_users() setup.setup_keyboard_map() setup.setup_locale() setup.setup_timezone() system.pinch_system( manager )
def __init__(self, name, password, email, os): super().__init__(name, password, email) self.os_privileges = Privileges(os)
def __init__(self, nome, sobrenome, idade): # Trazendo da classe-Pai: super().__init__(nome, sobrenome, idade) # Utilizando a class Privileges como instância self.privileges = Privileges()
def __init__(self, first_name, last_name): super().__init__(first_name, last_name) privs=['CanBan','CanModify','CanApprove'] # self.privileges=['CanModify', 'CanAuthorize', 'CanBan'] self.privileges=Privileges(privs)
def __init__(self, first_name, last_name): super(Admin, self).__init__(first_name, last_name) self.privileges = Privileges()
def __init__(self, first_name, last_name, age, location): """ """ super().__init__(first_name, last_name, age, location) # self.privileges = ['can add posts','can delete post','can ban user','can approve comments'] self.privilege = Privileges()
def process(self): self.manual = Help() if self.__help(): return Privileges.check_for_root_permissions() image_root = self.command_args['--target-dir'] + '/build/image-root' Path.create(image_root) if not self.global_args['--logfile']: log.set_logfile( self.command_args['--target-dir'] + '/build/image-root.log' ) self.load_xml_description( self.command_args['--description'] ) if self.command_args['--set-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(self.command_args['--set-repo']) self.xml_state.set_repository( repo_source, repo_type, repo_alias, repo_prio ) if self.command_args['--add-repo']: for add_repo in self.command_args['--add-repo']: (repo_source, repo_type, repo_alias, repo_prio) = \ self.quadruple_token(add_repo) self.xml_state.add_repository( repo_source, repo_type, repo_alias, repo_prio ) Path.create(self.command_args['--target-dir']) if os.path.exists('/.buildenv'): # This build runs inside of a buildservice worker. Therefore # the repo defintions is adapted accordingly self.xml_state.translate_obs_to_suse_repositories() elif self.command_args['--obs-repo-internal']: # This build should use the internal SUSE buildservice # Be aware that the buildhost has to provide access self.xml_state.translate_obs_to_ibs_repositories() log.info('Preparing new root system') system = System( self.xml_state, image_root, True ) manager = system.setup_repositories() system.install_bootstrap(manager) system.install_system( manager ) profile = Profile(self.xml_state) defaults = Defaults() defaults.to_profile(profile) setup = SystemSetup( self.xml_state, self.command_args['--description'], image_root ) setup.import_shell_environment(profile) setup.import_description() setup.import_overlay_files() setup.call_config_script() setup.import_image_identifier() setup.setup_groups() setup.setup_users() setup.setup_keyboard_map() setup.setup_locale() setup.setup_timezone() system.pinch_system( manager ) # make sure system instance is cleaned up now del system setup.call_image_script() # make sure setup instance is cleaned up now del setup log.info('Creating system image') image_builder = ImageBuilder( self.xml_state, self.command_args['--target-dir'], image_root ) result = image_builder.create() result.print_results() result.dump( self.command_args['--target-dir'] + '/kiwi.result' )
def __init__(self, first, last, age): super().__init__(first, last, age) self.privileges = Privileges(["can add post", "can delete user", "can ban user"])
def __init__(self, first_name, last_name, user, email, password): super().__init__(first_name, last_name, user, email, password) """Atributo exclusivo da classe filha""" self.privileges = Privileges()
def __init__(self, first, last, age='', gender=''): super().__init__(first, last, age, gender) self.privileges = Privileges()