コード例 #1
0
def CreateFile(user, ToolID, path):
    tool = GetTool(user, ToolID)
    if ToolPermissions.CanEdit(user, tool):
        if os.path.exists(path) and os.path.isfile(path):
            raise Exception("Cannot create file with this name. File already exists.")
        
        File.print_to_file(path, '', permissions=0755)
    else:
        raise PermissionDenied
コード例 #2
0
ファイル: jobs_acl.py プロジェクト: triicst/JMS
    def handle(self, *args, **options):
        temp_dir = os.path.join(settings.JMS_SETTINGS["JMS_shared_directory"],
                                "tmp/")

        user = User.objects.get(username=getpass.getuser())
        try:
            action = args[0]

            if action == "setup_job":
                job_stage_id = int(args[1])
                stage_index = int(args[2])

                jobstage = JobStages.GetJobStageByID(user, job_stage_id)

                temp_job_dir = os.path.join(temp_dir,
                                            ".%s/%d" % (user, job_stage_id))

                job_name = jobstage.Job.JobName
                script_name = "job.sh"

                parsed_settings = []
                for resource in jobstage.JobStageResources.all():
                    s = Setting(resource.Key, resource.Value)
                    parsed_settings.append(s)

                Directory.copy_directory(temp_job_dir,
                                         jobstage.WorkingDirectory)
                Directory.create_directory(os.path.dirname(jobstage.OutputLog))
                Directory.create_directory(os.path.dirname(jobstage.ErrorLog))

                #get dependencies
                has_dependencies = False
                if jobstage.Job.JobTypeID == 3:
                    has_dependencies = len(
                        jobstage.Stage.StageDependencies.all()) > 0

                #create job script
                r = ResourceManager(user)
                script = r.CreateJobScript(job_name.replace(' ', '_'),
                                           jobstage.WorkingDirectory,
                                           script_name, jobstage.OutputLog,
                                           jobstage.ErrorLog, parsed_settings,
                                           has_dependencies, jobstage.Commands)

                return script

        except Exception, ex:
            File.print_to_file("/tmp/%s_acl.log" % user.username, str(ex))
コード例 #3
0
ファイル: jobs_acl.py プロジェクト: RUBi-ZA/JMS
 def handle(self, *args, **options):
     temp_dir = os.path.join(settings.JMS_SETTINGS["JMS_shared_directory"], 
         "tmp/")
         
     user = User.objects.get(username=getpass.getuser())
     try:
         action = args[0]
         
         if action == "setup_job":
             job_stage_id = int(args[1])
             stage_index = int(args[2])
             
             jobstage = JobStages.GetJobStageByID(user, job_stage_id)
             
             temp_job_dir = os.path.join(temp_dir, ".%s/%d" % (user, job_stage_id))
             
             job_name = jobstage.Job.JobName
             script_name = "job.sh"
             
             parsed_settings = []
             for resource in jobstage.JobStageResources.all():
                 s = Setting(resource.Key, resource.Value)
                 parsed_settings.append(s)
             
             Directory.copy_directory(temp_job_dir, jobstage.WorkingDirectory)
             Directory.create_directory(os.path.dirname(jobstage.OutputLog))
             Directory.create_directory(os.path.dirname(jobstage.ErrorLog))
             
             #get dependencies
             has_dependencies = False
             if jobstage.Job.JobTypeID == 3:
                 has_dependencies = len(jobstage.Stage.StageDependencies.all()) > 0
             
             #create job script
             r = ResourceManager(user)
             script = r.CreateJobScript(job_name.replace(' ', '_'), 
                 jobstage.WorkingDirectory, script_name, jobstage.OutputLog, 
                 jobstage.ErrorLog, parsed_settings, has_dependencies, 
                 jobstage.Commands)
             
             return script
     
     except Exception, ex:
         File.print_to_file("/tmp/%s_acl.log" % user.username, str(ex))
コード例 #4
0
ファイル: Tools.py プロジェクト: sci-gaia/JMS
def ReadFile(user, ToolID, path):
    tool = GetTool(user, ToolID)
    if ToolPermissions.CanEdit(user, tool):
        return File.read_file(path)
    else:
        raise PermissionDenied
コード例 #5
0
ファイル: Tools.py プロジェクト: sci-gaia/JMS
def SaveFile(user, ToolID, path, content):
    tool = GetTool(user, ToolID)
    if ToolPermissions.CanEdit(user, tool):
        File.print_to_file(path, content, permissions=0777)
    else:
        raise PermissionDenied
コード例 #6
0
ファイル: Tools.py プロジェクト: davidbrownza/JMS
def ReadFile(user, ToolID, path):
    tool = GetTool(user, ToolID)
    if ToolPermissions.CanEdit(user, tool):
        return File.read_file(path)
    else:
        raise PermissionDenied
コード例 #7
0
ファイル: Tools.py プロジェクト: davidbrownza/JMS
def SaveFile(user, ToolID, path, content):
    tool = GetTool(user, ToolID)
    if ToolPermissions.CanEdit(user, tool):
        File.print_to_file(path, content, permissions=0777)
    else:
        raise PermissionDenied