Exemplo n.º 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
Exemplo n.º 2
0
    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))
Exemplo n.º 3
0
 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))
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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