Exemple #1
0
    def generate(self, name, mail1, mail2, waypoint_file):
        name = name.strip()
        if name == "":
            return self.error("No map name given!")
        
        mail1 = mail1.strip()
        mail2 = mail2.strip()
        if mail1 != mail2:
            return self.error("eMail addresses don't match!")
        
        if mail1 == "" or mail2 == "":
            return self.error("No eMail address given!")
        
        if not waypoint_file.file or not os.path.exists(waypoint_file.file.name):
            return self.error("Waypoint file could not be read!")
            
        uuid = self.generate_uuid()

        dir_job = self.create_dir_job(uuid)
        self.lock_job(uuid)
        
        path = os.path.join(dir_job, "waypoints.dat")
        f = open(path, "w")
        while True:
            data = waypoint_file.file.read(8192)
            if not data:
                break
            f.write(data)
        f.close()

        file_job = self.get_file_job(uuid)
        
        job = MapJob()
        job.name = name
        job.mail = mail1
        job.command = "generate"
        job.use_waypoint_file = True
           
        f = open(file_job, "wb")
        pickle.dump(job, f)
        f.close()
       
        self.unlock_job(uuid)
       
        return self.status(uuid)
Exemple #2
0
    def generate(self, name, mail1, mail2, waypoint_file):
        name = name.strip()
        if name == "":
            return self.error("No map name given!")

        mail1 = mail1.strip()
        mail2 = mail2.strip()
        if mail1 != mail2:
            return self.error("eMail addresses don't match!")

        if mail1 == "" or mail2 == "":
            return self.error("No eMail address given!")

        if not waypoint_file.file or not os.path.exists(
                waypoint_file.file.name):
            return self.error("Waypoint file could not be read!")

        uuid = self.generate_uuid()

        dir_job = self.create_dir_job(uuid)
        self.lock_job(uuid)

        path = os.path.join(dir_job, "waypoints.dat")
        f = open(path, "w")
        while True:
            data = waypoint_file.file.read(8192)
            if not data:
                break
            f.write(data)
        f.close()

        file_job = self.get_file_job(uuid)

        job = MapJob()
        job.name = name
        job.mail = mail1
        job.command = "generate"
        job.use_waypoint_file = True

        f = open(file_job, "wb")
        pickle.dump(job, f)
        f.close()

        self.unlock_job(uuid)

        return self.status(uuid)
Exemple #3
0
 def submit_terrain(self, resolution):
     cherrypy.session['resolution'] = resolution
     cherrypy.session.save()
     
     dir_job = self.get_dir_job(cherrypy.session.id)
     file_job = os.path.join(dir_job, "job")
     
     job = MapJob()
     job.command = "generate"
     job.output_file = os.path.join(dir_job, "map.xcm")
     job.resolution = cherrypy.session.get("resolution")
     if cherrypy.session.get("method") == "coordinates":
         job.bounds = cherrypy.session.get("bounds")
     else:
         job.waypoint_file = cherrypy.session.get("waypoint_file")
         
     f = open(file_job, "wb")
     pickle.dump(job, f)
     f.close()
     
     self.unlock_job(dir_job)
     
     return self.status()