Пример #1
0
    def PrintGitLog(self, repertory_L):

        Log.Info("The repertory info list is:")
        manifest_str = ""
        for repertory in repertory_L:
            if repertory == "LINUX" or repertory == "proprietary":
                log_cmd = "git log -1 -b proprietary_master --pretty=\"%H<gitlog>%s\""
            else:
                local_branch = repertory.replace("/", "__")
                log_cmd = "git log -1 -b %s_master --pretty=\"%%H<gitlog>%%s\"" % (local_branch)
            status, output = commands.getstatusoutput(log_cmd)

            if status == 0:
                temp_L = output.strip().split("<gitlog>")
                Log.Red("%25s %s\n" % (repertory, temp_L))
                git_commit_id = temp_L[0]

                if self.qcom_base == "proprietary": # 表明是proprietary需要分仓
                    manifest_str += "  <project name=\"platform/vendor/qcom/proprietary/%s\" path=\"vendor/qcom/proprietary/%s\" revision=\"%s\" />\n" % (
                        repertory, repertory, self.targetbranch)
                else:
                    # 其他的表示 高通的大仓库需要分仓
                    if repertory == "LINUX" or repertory == "proprietary":
                        manifest_str += "  <project name=\"platform/vendor/qcom/proprietary\" path=\"vendor/qcom/proprietary\" revision=\"%s\" />\n" % (
                        git_commit_id)
                    else:
                        manifest_str +="  <project name=\"AMSS/%s\" path=\"AMSS/%s\" revision=\"%s\" />\n" % (
                        repertory, repertory, git_commit_id)

        Log.Blue("\n%s\n" % manifest_str)
Пример #2
0
    def Execute(self):
        try:
            default_passwd = "123456"

            for (account, email) in self.username:
                Log.Blue(
                    "\n===============================================================\n"
                )
                if not self.dryrun: self.default_mail_list.append(email)
                #判断一下这个帐号是不是已经存在了,存在就打印错误,继续下一个
                if account not in self.GetAllNormalUserName(
                ) or email not in self.GetComment(account):
                    # 判断是否在 用户列表中, 还要判断全名是否在这个用户的comment字段下面
                    Log.Error("%s not exists" % (account))
                    raise ManageUserException("%s not exists" % account)

                # 设置帐号密码
                cmd = "sudo bash -c \"echo -ne %s:%s | chpasswd\"" % (
                    account, default_passwd)
                Log.Info("reset passwd cmd: [%s]" % cmd)
                if not self.dryrun and os.system(cmd) != 0:
                    raise ManageUserException("reset passwd fail")

                # 重置密码就要发邮件给 用户了
                self.success_mail_list.append(email)
            # end for结束遍历
            Log.Info("will send pass mail")
            self.SendPassMail()
        except Exception as e:
            Log.Error("reset passwd fail: %s, will send fail mail" % e)
            traceback.print_exc()
            self.SendFailMail("%s" % (e))
            return 1
        return 0
Пример #3
0
 def Execute(self):
     try:
         default_work = "/work"
         for (account, email) in self.username:
             Log.Blue(
                 "\n===============================================================\n"
             )
             if account not in self.GetAllNormalUserName(
             ) or email not in self.GetComment(account):
                 Log.Error("%s is not exists" % (account))
                 raise ManageUserException("%s not exists" % account)
             cmd = "sudo bash -c \"userdel -r %s\"" % (account)
             Log.Info("delete user cmd: [%s]" % cmd)
             if not self.dryrun and os.system(cmd) != 0:
                 raise ManageUserException("delete user fail")
             cmd = "sudo bash -c \"rm -rf %s\"" % (os.path.join(
                 default_work, account))
             Log.Info("delete user work dir cmd: [%s]" % cmd)
             if not self.dryrun and os.system(cmd) != 0:
                 raise ManageUserException("delete user work folder fail")
         Log.Info("will send pass mail")
         self.SendPassMail()
     except Exception as e:
         Log.Error("delete user fail: %s, will send fail mail" % e)
         traceback.print_exc()
         self.SendFailMail("%s" % (e))
         return 1
     return 0
Пример #4
0
    def Execute(self):
        try:
            for (account, email) in self.username:
                # 这里的account 就是 登陆时候的账号,email就是这个员工的邮箱地址
                Log.Blue(
                    "\n===============================================================\n"
                )
                if not self.dryrun: self.default_mail_list.append(email)
                cmd = "sudo bash -c \"usermod -c %s %s\"" % (email, account)
                Log.Info("lock user cmd: [%s]" % cmd)
                if not self.dryrun and os.system(cmd) != 0:
                    raise ManageUserException("update user comment fail")
            Log.Info("will send pass mail")
            self.SendPassMail()
        except Exception as e:
            Log.Error("update user comment fail: %s, will send fail mail" % e)
            traceback.print_exc()
            self.SendFailMail("%s" % (e))
            return 1

        return 0
Пример #5
0
 def Execute(self):
     try:
         for (account, email) in self.username:
             Log.Blue(
                 "\n===============================================================\n"
             )
             if account not in self.GetAllNormalUserName(
             ) or email not in self.GetComment(account):
                 Log.Error("%s is not exists" % (account))
                 raise ManageUserException("%s not exists" % account)
             cmd = "sudo bash -c \"usermod -L %s\"" % (account)
             Log.Info("lock user cmd: [%s]" % cmd)
             if not self.dryrun and os.system(cmd) != 0:
                 raise ManageUserException("lock user fail")
         Log.Info("will send pass mail")
         self.SendPassMail()
     except Exception as e:
         Log.Error("lock user fail: %s, will send fail mail" % e)
         traceback.print_exc()
         self.SendFailMail("%s" % (e))
         return 1
     return 0
Пример #6
0
    def Execute(self):
        try:
            default_passwd = "123456"
            default_work = "/work"

            for (account, email) in self.username:
                Log.Blue(
                    "\n===============================================================\n"
                )
                if not self.dryrun: self.default_mail_list.append(email)
                #判断一下这个帐号是不是已经存在了,存在就打印错误,继续下一个
                all_username_L = self.GetAllUserName()
                if account in all_username_L:
                    Log.Error("%s is already exists" % (account))
                    raise ManageUserException("%s is already exists" % account)

                #add user
                cmd = "sudo bash -c \"useradd -m -s /bin/bash -c %s %s\" " % (
                    email, account)
                Log.Info("adduser cmd: [%s]" % cmd)
                if not self.dryrun and os.system(cmd) != 0:
                    raise ManageUserException("adduser fail")

                # 设置帐号密码
                cmd = "sudo bash -c \"echo -ne %s:%s | chpasswd\"" % (
                    account, default_passwd)
                Log.Info("set passwd cmd: [%s]" % cmd)
                if not self.dryrun and os.system(cmd) != 0:
                    raise ManageUserException("set passwd fail")

                # 设置smb的帐号密码
                cmd = "sudo bash -c 'echo -ne \"%s\\n%s\\n\" |smbpasswd -a -s %s'" % (
                    default_passwd, default_passwd, account)
                Log.Info("set smb passwd cmd: [%s]" % cmd)
                if not self.dryrun and os.system(cmd) != 0:
                    raise ManageUserException("set smb passwd fail")

                # 创建连接 work 文件
                user_work = os.path.join(default_work, account)
                link_work = "/home/%s/work" % (account)
                cmd = "sudo bash -c \"mkdir -p %s && chown %s:%s %s -R\"" % (
                    user_work, account, account, user_work)
                Log.Info("create work path cmd: [%s]" % cmd)
                if not self.dryrun and os.system(cmd) != 0:
                    raise ManageUserException("create user work path fail")

                # 创建连接 work的文件
                cmd = "sudo bash -c \"ln -s %s %s && chown %s:%s %s -h\"" % (
                    user_work, link_work, account, account, link_work)
                Log.Info("create link work file cmd: [%s]" % cmd)
                if not self.dryrun and os.system(cmd) != 0:
                    raise ManageUserException("create link work file fail")

                # 添加新的用户也是要发邮件给 用户了
                self.success_mail_list.append(email)
            # end for
            Log.Info("will send pass mail")
            self.SendPassMail()
        except Exception as e:
            Log.Error("adduser fail: %s, will send fail mail" % e)
            traceback.print_exc()
            self.SendFailMail("%s" % (e))
            return 1
        return 0