Ejemplo n.º 1
0
def createSpotDirectories(spot):
    if not os.path.exists(spot.path):
        print("Creating spot directory for %s/%s" %
              (spot.job.dir_name, spot.dir_name))
        os.mkdir(spot.path)
        utils.chown(spot.path, 0, 600)
        os.chmod(spot.path, 0555)

    # create spot subdirs
    spotsConfig = 'directory-spots.config'
    if spot.schema > 1:
        spotsConfig = 'directory-spots-v2.config'

    with open(os.path.join(PATHS['CHRLX_3D_CFG'], spotsConfig)) as f:
        for p in f:
            p = p.strip()
            if not p:
                continue
            if p.startswith('#'):
                continue

            thispath = os.path.join(spot.path, p.lstrip('/'))
            if not os.path.exists(thispath):
                os.mkdir(thispath)
                os.chmod(thispath, 0777)
                utils.chown(thispath, 0, 600)

    if not os.path.exists(os.path.join(spot.projectPath, 'workspace.mel')):
        shutil.copy(os.path.join(PATHS['CHRLX_3D_CFG'], 'workspace.mel'),
                    spot.projectPath)
        os.chmod(os.path.join(spot.projectPath, 'workspace.mel'), 0644)

    # mark spot done
    spot.status = 'A'
    Session.commit()
Ejemplo n.º 2
0
def createShot(jobname,
               spotname,
               shotname,
               fps=None,
               startframe=None,
               endframe=None,
               camera=None,
               resolution=None,
               description=None,
               uid=None):
    """create new shot by calling the existing perl script"""
    if not uid:
        uid = utils.getCurrentUser()
    shotnum = int(shotname[-3:])
    stage = shotname[:-3]
    spotPath = utils.PathManager(
        os.path.join(PATHS['CHRLX_JOBS'], jobname, spotname))
    shot = Session.query(Shot).filter_by(spotid=spotPath.spot.id,
                                         shot=shotnum,
                                         stage=stage).first()
    if not shot:
        shot = Shot(spotid=str(spotPath.spot.id),
                    uid=uid,
                    shot=shotnum,
                    stage=stage,
                    start_frame=startframe,
                    end_frame=endframe,
                    fps=fps,
                    resolution=resolution,
                    camera=camera,
                    description=description)
        Session.add(shot)
        Session.commit()
        print "Adding Shot", spotPath.spot, shotname
    else:
        print "Shot Exists", spotPath.spot, shotname
    shotsConfig = 'directory-shots.config'
    if spotPath.spot.schema > 1:
        shotsConfig = 'directory-shots-v2.config'
    with open(os.path.join(PATHS['CHRLX_3D_CFG'], shotsConfig)) as f:
        for p in f:
            p = p.strip()
            if not p:
                continue
            if p.startswith('#'):
                continue
            p = p.lstrip('/')
            thispath = os.path.join(spotPath, p % (stage, shotnum))
            if not os.path.exists(thispath):
                os.mkdir(thispath)
                os.chmod(thispath, 0777)
                utils.chown(thispath, 0, 600)

    return utils.PathManager(shot.path)
Ejemplo n.º 3
0
    def __getattr__(self, name):
        if not self.dbhandle:
            from chrlx.model.jobs import Job, Spot, Shot
            from chrlx.model.meta import Session
            self.dbhandle = Session.query(Job).filter(
                Job.dir_name == self.dir_name).first()

            if not self.dbhandle:
                raise KeyError("Job does not exist in db.")
        return getattr(self.dbhandle, name)
Ejemplo n.º 4
0
 def __getattr__(self, name):
     if not self.dbhandle:
         from chrlx.model.jobs import Job, Spot, Shot
         from chrlx.model.meta import Session
         from sqlalchemy import or_, and_
         self.dbhandle = Session.query(Spot).filter(
             and_(Spot.dir_name == self.dir_name,
                  Spot.jobid == self.job.id)).first()
         if not self.dbhandle:
             raise KeyError("Spot {0} does not exist in job {1}.".format(
                 self.dir_name, self.job.jobDirname))
     return getattr(self.dbhandle, name)
Ejemplo n.º 5
0
def run():
    ## create new job directories
    for job in Session.query(Job).filter_by(status='N'):
        if os.path.isdir(job.path):
            print("%s already exists, marking active" % job.dir_name)
            job.status = 'A'
            Session.commit()
        else:
            createJobDirectories(job)
            sendJobEmail(job)

    ## create new spot directories - must do this by job,
    ## but only for active jobs
    for job in Session.query(Job).filter_by(status='A'):
        newSpots = []
        for spot in job.spots:
            if spot.status != 'N':
                continue
            if os.path.isdir(spot.path):
                print("%s/%s already exists, marking active" %
                      (spot.job.dir_name, spot.dir_name))
                spot.status = 'A'
                Session.commit()

            else:
                createSpotDirectories(spot)
                newSpots.append(spot)

        if newSpots:
            sendJobEmail(job, newSpots)
Ejemplo n.º 6
0
    def __getattr__(self, name):
        if "frames" in name or "plates" in name:
            if "restored" in name:
                return self.shotFrames(name,True)
            else:
                return self.shotFrames(name)

        if not self.dbhandle:
            from chrlx.model.jobs import Job, Spot, Shot
            from chrlx.model.meta import Session
            from sqlalchemy import or_, and_
            self.dbhandle=Session.query(Shot).filter(and_(Shot.spotid==self.spot.id,
                                         Shot.shot==self.shot,
                                         Shot.stage==self.stage)).first()
            if not self.dbhandle:
                raise KeyError("Shot {0} does not exist in spot {1}.".format(self.shotName, self.spot.id))
        return getattr(self.dbhandle, name)
Ejemplo n.º 7
0
            createSpotDirectories(spot)
            spots.append(spot)

    # calendar directory
    caldir = os.path.join(job.path, 'calendar')
    os.mkdir(caldir)
    os.chmod(caldir, 0777)

    # make sure job/spot paths are read-only
    utils.chown(job.path, 0, 600)
    os.chmod(job.path, 0555)

    # mark the job done, and save it all
    job.status = 'A'
    job.addComment(uid='rush3d', subject='Job directory created')
    Session.commit()


def createSpotDirectories(spot):
    if not os.path.exists(spot.path):
        print("Creating spot directory for %s/%s" %
              (spot.job.dir_name, spot.dir_name))
        os.mkdir(spot.path)
        utils.chown(spot.path, 0, 600)
        os.chmod(spot.path, 0555)

    # create spot subdirs
    spotsConfig = 'directory-spots.config'
    if spot.schema > 1:
        spotsConfig = 'directory-spots-v2.config'