How to use get_group_name_id method in autotest

Best Python code snippet using autotest_python

service_helper.py

Source:service_helper.py Github

copy

Full Screen

...35 pass_info = pwd.getpwuid(user)36 else:37 pass_info = pwd.getpwnam(user)38 return pass_info[0], pass_info[2]39def get_group_name_id(group):40 """41 Get the group id # and name42 @param group: integer or string containing either the uid #43 or a string username44 @returns a tuple of group name, group id45 """46 if re.match('\d+', str(group)):47 group_info = grp.getgrgid(group)48 else:49 group_info = grp.getgrnam(group)50 return group_info[0], group_info[2]51def set_group_user(group=None, user=None):52 """53 Set the group and user id if gid or uid is defined.54 @param group: Change the group id the program is run under55 @param user: Change the user id the program is run under56 """57 if group:58 _, gid = get_group_name_id(group)59 os.setgid(gid)60 os.setegid(gid)61 if user:62 username, uid = get_user_name_id(user)63 # Set environment for programs that use those to find running user64 for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):65 os.environ[name] = username66 os.setuid(uid)67 os.seteuid(uid)68def main():69 parser = optparse.OptionParser()70 parser.allow_interspersed_args = False71 parser.add_option('-l', '--logfile', action='store',72 default=None,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful