Exemple #1
0
    def get(self):
        #Upon redirection sends the datagen html
        fileName = self.getLasDatFileName()
        self.prbLoc = self.get_prbfilename()
        f = fileHandler.FileHandler(self.current_user)
        f.someFiles(["*.dat"], Settings.DAT_FILE_LOCATION + self.prbLoc + "/")

        #         listOfFiles = []
        filePathtoUserDirectory = os.path.join(Settings.UPLOAD_LOCATION,
                                               self.current_user)
        #
        if not fileName:
            data = 'No data file selected.'
        else:
            fileReader = open(os.path.join(filePathtoUserDirectory, fileName),
                              "r")
            data = fileReader.read()

        var = {"data": data}
        flist = {
            "fileNames": f.listOfFiles,
            "currentDatFile": "",
            "currentFile": self.get_prbfilename()
        }
        var = json.dumps(var)
        flist = json.dumps(flist)
        self.render("dataGen.html", arg=var, arg2=flist)
Exemple #2
0
    def post(self):
        #Method to handle the request when a file is uploaded
        #Should be deprecated if not required afterwards
        fileinfo = self.request.files['filearg'][0]
        fname = fileinfo['filename']

        cname = str(fname)
        filePath = os.path.join(Settings.UPLOAD_LOCATION, self.current_user,
                                Settings.PRB_FILE_LOCATION)
        fh = open(os.path.join(filePath, cname), 'w')
        fh.write(fileinfo['body'])
        fh.close()

        #data = open(Settings.UPLOAD_LOCATION + self.current_user + "/" + Settings.PRB_FILE_LOCATION + cname, 'r').read()
        #data = json.dumps(data)

        f = fileHandler.FileHandler(self.current_user)
        f.someFiles(["*.prb"], Settings.PRB_FILE_LOCATION)
        fileTree = f.fileTree(["*.prb"], Settings.PRB_FILE_LOCATION, ["*.dat"],
                              Settings.DAT_FILE_LOCATION)

        var = {"data": ""}
        flist = {
            "fileTree": fileTree,
            "fileNames": f.listOfFiles,
            "currentFile": fname
        }  #, "downloadLink": Settings.DOWNLOAD_LOCATION + self.current_user + "/" + "install_bcg.zip"}
        var = json.dumps(var)
        flist = json.dumps(flist)
        self.render("codeGen.html", arg=var, arg2=flist)
Exemple #3
0
 def get(self):
     #Sends the download location of data
     fileName = self.get_argument("fileName")
     prbfileName = self.get_argument("PRB")
     fileName = fileName.split(".")[0]
     fH = fileHandler.FileHandler(self.current_user)
     path = fH.findDataDownloadLink(fileName=fileName,
                                    prbFilename=prbfileName)
     self.write(json.dumps(path))
Exemple #4
0
 def get(self):
     # Removes a dat file
     fileName = self.get_argument("fileName")
     prbFileName = self.get_argument("prbFileName")
     fH = fileHandler.FileHandler(self.current_user)
     path = fH.returnPRBLoc(prbFileName)
     datPath = os.path.join(path, fileName)
     msg = subprocess.call(["rm", datPath])
     if msg == 0:
         self.write("success")
     else:
         self.write("failed")
Exemple #5
0
    def get(self):
        #deletes prb file from disc and corresponding directory for dat files
        fileName = self.get_argument("fileName")
        if fileName.split(".").__len__() == 1:
            fileName = fileName + ".prb"
        fH = fileHandler.FileHandler(self.current_user)
        msg = fH.deletePrbAndDat(fileName)

        if msg == 0:
            self.write("success")
        else:
            self.write("failed")
Exemple #6
0
    def get(self):
        #Upon redirected codegen page it sends the codegen html along
        #with the file tree structure for the user
        fileName = self.get_argument("fileName", default=None)

        f = fileHandler.FileHandler(self.current_user)
        f.someFiles(["*.prb"], Settings.PRB_FILE_LOCATION)

        #         listOfFiles = []
        filePathtoUserDirectory = os.path.join(Settings.UPLOAD_LOCATION,
                                               self.current_user)

        if not fileName:
            data = 'No file selected.'
        else:
            fileReader = open(os.path.join(filePathtoUserDirectory, fileName),
                              "r")
            data = fileReader.read()

        fileTree = f.fileTree(["*.prb"], Settings.PRB_FILE_LOCATION, ["*.dat"],
                              Settings.DAT_FILE_LOCATION)

        var = {"data": data}
        currentFile = ""
        currentDatFile = ""
        try:
            currentFile = self.get_argument("currentFile")
            try:
                currentDatFile = self.get_argument("currentDatFile")
            except:
                pass
        except:
            pass
        flist = {
            "fileTree": fileTree,
            "fileNames": f.listOfFiles,
            "currentFile": currentFile,
            "currentDatFile": currentDatFile
        }
        var = json.dumps(var)
        flist = json.dumps(flist)
        self.render("codeGen.html", arg=var, arg2=flist)
Exemple #7
0
    def post(self):
        fileinfo = self.request.files['file'][0]
        fname = fileinfo['filename']
        cname = str(fname)
        datPath = os.path.join(Settings.UPLOAD_LOCATION, self.current_user,\
                               Settings.DAT_FILE_LOCATION, self.get_prbfilename())
        fh = open(datPath + cname, 'w')
        fh.write(fileinfo['body'])
        fh.close()

        f = fileHandler.FileHandler(self.current_user)
        f.someFiles(["*.dat"], absolutePath=datPath)

        var = {"data": ""}
        flist = {
            "fileNames": f.listOfFiles,
            "currentDatFile": fname,
            "currentFile": self.get_prbfilename()
        }  #, "downloadLink": Settings.DOWNLOAD_LOCATION + self.current_user + "/" + "install_bcg.zip"}
        var = json.dumps(var)
        flist = json.dumps(flist)
        self.render("dataGen.html", arg=var, arg2=flist)
Exemple #8
0
import fileReader
import inputHandler
import fileHandler
import os

inputStuff = inputHandler.inputHandler()
fileStuff = fileHandler.FileHandler()
def getMode():
	mode = inputStuff.determineAutoOrManual()
	if mode == 'man':
		getFileInfo()
		loadAudioFile()
	elif mode =='auto':
		fileProcesser = fileReader.FileReader()
		fileProcesser.processFile(inputStuff.getFileName())
def getFileInfo():
	filename = inputStuff.getFileName()
	if os.path.isfile(filename):
		fileStuff.setFileName(filename)
	else:
		print('file not found, please try again.')
		getFileInfo()
def loadAudioFile():
	try:
		fileStuff.loadFile()
	except Exception:
		print('error: not an audio file')
		getFileInfo()
	fileStuff.splitFile(inputStuff.getSplitTimes())
getMode()
Exemple #9
0
def startFH(FHPipeFHEnd):
	import fileHandler

	fileHandler.FileHandler(FHPipeFHEnd).loop()
Exemple #10
0
def main(argv):
    comm = MPI.COMM_WORLD
    pid = comm.rank
    size = comm.size
    rho = 0
    gamma = 0
    s = 0
    luciferin = 0
    k = 0
    m = 0
    wormList = []
    CC = []
    intraDistances = []
    wormListAux = []
    indexList = []
    SSE = 0
    ratio = 1.5
    totalWorms = 1000  #Las pruebas hechas siempre fueron con 20 gusanos
    neighborMatrix = [[]]
    if (pid == 0):
        rho, gamma, s, luciferin, k, m = obtenerValoresLineaComandos(argv)
        indexList = initSetUp()
    rho, gamma, s, luciferin, k, m, indexList = comm.bcast(
        (rho, gamma, s, luciferin, k, m, indexList), 0)
    pidTotalWorms = int(totalWorms / size)
    minRange = int(pid * pidTotalWorms)
    wormList, intraDistances, wormListAux = createWorms(
        k, luciferin, ratio, indexList, pidTotalWorms, minRange)
    finalWormList = comm.reduce(wormList, op=MPI.SUM)
    finalIntraDistances = comm.reduce(intraDistances, op=MPI.SUM)
    finalWormListAux = comm.reduce(wormListAux, op=MPI.SUM)
    if (pid == 0):
        CC = subconjuntoDatos(finalWormList, ratio, 0)
        neighborMatrix = createNeighborMatrix(finalWormListAux)
        SSE = equations.EQ6(CC, k)
        # InterDist = EQ7(k, CC, wormList)
    comm.Barrier()
    finalWormList, finalIntraDistances, finalWormListAux, CC, neighborMatrix, SSE = comm.bcast(
        (finalWormList, finalIntraDistances, finalWormListAux, CC,
         neighborMatrix, SSE), 0)
    minRange = int(pid * len(finalWormList) / size)
    maxRange = int((pid + 1) * len(finalWormList) / size)
    comm.Barrier()
    finalWormList = comm.reduce(wormList, op=MPI.SUM)
    contador = 0
    comm.Barrier()
    largoCentroides = len(CC)
    if (pid == 0):
        while (largoCentroides > k):
            contador += 1
            if (pid == 0):
                finalWormList = gso(finalWormList, m, s, gamma, ratio,
                                    luciferin, CC, k, SSE, rho, indexList,
                                    finalIntraDistances, neighborMatrix,
                                    finalWormListAux, minRange, maxRange)
                CC = subconjuntoDatos(finalWormList, ratio, largoCentroides)
                print("CC al final del ciclo: " + str(contador) + " = " +
                      str(len(CC)))
                largoCentroides = len(CC)
                SSE = equations.EQ6(CC, k)
                interDist = equations.EQ7(k, CC, wormList)
            # CC, SSE,finalWormList = comm.bcast((CC, SSE, finalWormList),0)
            # comm.Barrier()
        finalResultsWriter = fileHandler.FileHandler()
        finalResultsWriter.writeFinalResults(FINAL_RESULTS_FILENAME, CC)

    #Ciclo paralelizado
    """
Exemple #11
0
 def get(self):
     fileName = self.get_argument("fileName")
     fileName = fileName.split(".")[0] + Settings.muoPrefix + ".zip"
     fH = fileHandler.FileHandler(self.current_user)
     path = fH.findDownloadLink(fileName)
     self.write(json.dumps(path))