<s> from mongoengine import NotUniqueError <EOL> from st2common . rbac . types import SystemRole <EOL> from st2common . persistence . rbac import Role <EOL> from st2common . models . db . rbac import RoleDB <EOL> from st2common . exceptions . db import StackStormDBObjectConflictError <EOL> __all__ = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> def run_all ( ) : <EOL> insert_system_roles ( ) <EOL> delete_mistyped_role ( ) <EOL> def insert_system_roles ( ) : <EOL> """<STR_LIT>""" <EOL> system_roles = SystemRole . get_valid_values ( ) <EOL> for role_name in system_roles : <EOL> description = role_name <EOL> role_db = RoleDB ( name = role_name , description = description , system = True ) <EOL> try : <EOL> Role . insert ( role_db , log_not_unique_error_as_debug = True ) <EOL> except ( StackStormDBObjectConflictError , NotUniqueError ) : <EOL> pass <EOL> delete_mistyped_role ( ) <EOL> def delete_mistyped_role ( ) : <EOL> """<STR_LIT>""" <EOL> role_name = '<STR_LIT>' <EOL> assert ( role_name . startswith ( '<STR_LIT:U+0020>' ) ) <EOL> try : <EOL> role_db = Role . get_by_name ( role_name ) <EOL> except : <EOL> return <EOL> if not role_db : <EOL> return <EOL> try : <EOL> Role . delete ( role_db ) <EOL> except : <EOL> return </s>
