parameters: ()
return_statement: return rand_pwd
docstring: function: get random passwd
          input: NA
          output: passwd
docstring_summary: function: get random passwd
          input: NA
          output: passwd
docstring_tokens: function : get random passwd input : NA output : passwd
function: def get_rand_str():
          """
          function: get random passwd
          input: NA
          output: passwd
          """
          uppercmd = 'openssl rand -base64 12 | tr "[0-9][a-z]" "[A-Z]" | tr -d [/+=] |cut -c 1-3'
          lowercmd = 'openssl rand -base64 12 | tr "[0-9][A-Z]" "[a-z]" | tr -d [/+=] |cut -c 1-4'
          numcmd = 'openssl rand -base64 12 | md5sum | tr "[a-z]" "[0-9]" |cut -c 1-3'
          strcmd = 'openssl rand -base64 48 | tr "[0-9][a-z][A-Z]" "[~@_#*]" | tr -d [/+=] |cut -c 1-1'
  
          upper_code, upper_output, upper_error = CommonTools.get_status_output_error(uppercmd)
          lower_code, lower_output, lower_error = CommonTools.get_status_output_error(lowercmd)
          num_code, num_output, num_error = CommonTools.get_status_output_error(numcmd)
          str_code, str_output, str_error = CommonTools.get_status_output_error(strcmd)
          if any([upper_code, lower_code, num_code, str_code]):
              raise Exception(Errors.EXECUTE_RESULT['gauss_0412'] % str(
                  [upper_code, lower_code, num_code, str_code]))
          rand_pwd = 'G' + upper_output.strip() + lower_output.strip() + \
                   num_output.strip() + str_output.strip()
          if len(rand_pwd) == Constant.RANDOM_PASSWD_LEN:
              return rand_pwd
          rand_pwd = "G"
          cmd_tuple = (uppercmd, lowercmd, numcmd, strcmd)
          out_tuple = (upper_output.strip(), lower_output.strip(),
                       num_output.strip(), str_output.strip())
          str_len = (3, 4, 3, 1)
          for i in range(4):
              if len(out_tuple[i]) != str_len[i]:
                  count = 0
                  while True:
                      count += 1
                      _, output, _ = CommonTools.get_status_output_error(cmd_tuple[i])
                      if len(output.strip()) == str_len[i]:
                          rand_pwd += output.strip()
                          break
                      if count > 100:
                          raise Exception(Errors.EXECUTE_RESULT[
                                              'gauss_0413'] % (cmd_tuple[i], 'generate rand pwd'))
              else:
                  rand_pwd += out_tuple[i].strip()
          return rand_pwd
function_tokens: def get_rand_str ( ) : uppercmd = 'openssl rand -base64 12 | tr "[0-9][a-z]" "[A-Z]" | tr -d [/+=] |cut -c 1-3' lowercmd = 'openssl rand -base64 12 | tr "[0-9][A-Z]" "[a-z]" | tr -d [/+=] |cut -c 1-4' numcmd = 'openssl rand -base64 12 | md5sum | tr "[a-z]" "[0-9]" |cut -c 1-3' strcmd = 'openssl rand -base64 48 | tr "[0-9][a-z][A-Z]" "[~@_#*]" | tr -d [/+=] |cut -c 1-1' upper_code , upper_output , upper_error = CommonTools . get_status_output_error ( uppercmd ) lower_code , lower_output , lower_error = CommonTools . get_status_output_error ( lowercmd ) num_code , num_output , num_error = CommonTools . get_status_output_error ( numcmd ) str_code , str_output , str_error = CommonTools . get_status_output_error ( strcmd ) if any ( [ upper_code , lower_code , num_code , str_code ] ) : raise Exception ( Errors . EXECUTE_RESULT [ 'gauss_0412' ] % str ( [ upper_code , lower_code , num_code , str_code ] ) ) rand_pwd = 'G' + upper_output . strip ( ) + lower_output . strip ( ) + num_output . strip ( ) + str_output . strip ( ) if len ( rand_pwd ) == Constant . RANDOM_PASSWD_LEN : return rand_pwd rand_pwd = "G" cmd_tuple = ( uppercmd , lowercmd , numcmd , strcmd ) out_tuple = ( upper_output . strip ( ) , lower_output . strip ( ) , num_output . strip ( ) , str_output . strip ( ) ) str_len = ( 3 , 4 , 3 , 1 ) for i in range ( 4 ) : if len ( out_tuple [ i ] ) != str_len [ i ] : count = 0 while True : count += 1 _ , output , _ = CommonTools . get_status_output_error ( cmd_tuple [ i ] ) if len ( output . strip ( ) ) == str_len [ i ] : rand_pwd += output . strip ( ) break if count > 100 : raise Exception ( Errors . EXECUTE_RESULT [ 'gauss_0413' ] % ( cmd_tuple [ i ] , 'generate rand pwd' ) ) else : rand_pwd += out_tuple [ i ] . strip ( ) return rand_pwd