Ejemplo n.º 1
0
    def startProcess(self, movies, length):
        stats = {"added": 0, "updated": 0, "removed": 0}

        for count, movie in enumerate(movies):
            if util.abortRequested() or (not(HIDE_TOP250) and self.progress.iscanceled()):
                break

            result = self.checkMovie(movie)
            if result != None:
                stats[result] += 1

            if not(HIDE_TOP250):
                self.progress.update((count * 100) // length, "%s %s" % (l("Searching_for"), movie["label"]))
        else:
            util.writeDate("top250")
            self.createMissingCSV()
            if OPEN_MISSING:
                util.openFile("missingTop250.csv")

        stats["missing"] = len(self.top250)
        util.log("Movies IMDb Top250 summary: updated: %(updated)s, added: %(added)s, removed: %(removed)s, missing: %(missing)s" % stats)

        if HIDE_TOP250:
            util.notification("%s %s" % (l("Completed"), l("Top250")))
        else:
            util.dialogOk(l("Completed"), l("Movies_IMDb_Top250_summary"), "%s %s" % (stats["updated"], l("were_updated")), "%s %s %s %s" % (stats["added"], l("were_added_and"), stats["removed"], l("were_removed!")))
Ejemplo n.º 2
0
    def startProcess(self, movies, length):
        stats = {"added": 0, "updated": 0, "removed": 0}

        for count, movie in enumerate(movies):
            if util.abortRequested() or (not (HIDE_TOP250)
                                         and self.progress.iscanceled()):
                break

            result = self.checkMovie(movie)
            if result != None:
                stats[result] += 1

            if not (HIDE_TOP250):
                self.progress.update(
                    (count * 100) // length,
                    "%s %s" % (l("Searching_for"), movie["label"]))
        else:
            util.writeDate("top250")
            self.createMissingCSV()
            if OPEN_MISSING:
                util.openFile("missingTop250.csv")

        stats["missing"] = len(self.top250)
        util.log(
            "Movies IMDb Top250 summary: updated: %(updated)s, added: %(added)s, removed: %(removed)s, missing: %(missing)s"
            % stats)

        if HIDE_TOP250:
            util.notification("%s %s" % (l("Completed"), l("Top250")))
        else:
            util.dialogOk(
                l("Completed"), l("Movies_IMDb_Top250_summary"),
                "%s %s" % (stats["updated"], l("were_updated")),
                "%s %s %s %s" % (stats["added"], l("were_added_and"),
                                 stats["removed"], l("were_removed!")))
Ejemplo n.º 3
0
Archivo: ft.py Proyecto: Lanozavr/pvs
    def OnDropFiles(self, x, y, fullnames):
        logging.debug("These files were dropped: %s", fullnames)
        for fullname in fullnames:
            fileExtension = os.path.splitext(fullname)[1]
            if fileExtension == PVS_EXTENSION:
                util.openFile(fullname)


                                    
Ejemplo n.º 4
0
def onOpenFile(event):
    """called to handle 'open file' request"""
    logging.debug("Starting")
    frame = util.getMainFrame()
    filters = "PVS files (*" + PVS_EXTENSION + ")|*" + PVS_EXTENSION
    dialog = wx.FileDialog (frame, "Open PVS file", wildcard = filters, style = wx.OPEN )
    if dialog.ShowModal() == wx.ID_OK:
        fullname = dialog.GetPath()
        logging.info("Opening file %s", fullname)
        util.openFile(fullname)
    else:
        logging.info("Nothing was selected.")
    dialog.Destroy()
Ejemplo n.º 5
0
def onCreateNewFile(event):
    """called to handle 'create new file' request"""
    logging.debug("Starting")
    frame = util.getMainFrame()
    filters = "PVS files (*" + PVS_EXTENSION + ")|*" + PVS_EXTENSION
    dialog = wx.FileDialog (frame, "Create a new PVS file", wildcard = filters, style = wx.SAVE | wx.OVERWRITE_PROMPT )
    if dialog.ShowModal() == wx.ID_OK:
        fullname = dialog.GetPath()
        if not fullname.endswith(PVS_EXTENSION):
            fullname = fullname + PVS_EXTENSION
        logging.info("Creating new file %s", fullname)
        util.openFile(fullname)
    else:
        logging.info("Nothing was selected.")
    dialog.Destroy()
Ejemplo n.º 6
0
def onOpenFile(event):
    """called to handle 'open file' request"""
    logging.debug("Starting")
    frame = util.getMainFrame()
    filters = "PVS files (*" + PVS_EXTENSION + ")|*" + PVS_EXTENSION
    dialog = wx.FileDialog(frame,
                           "Open PVS file",
                           wildcard=filters,
                           style=wx.OPEN)
    if dialog.ShowModal() == wx.ID_OK:
        fullname = dialog.GetPath()
        logging.info("Opening file %s", fullname)
        util.openFile(fullname)
    else:
        logging.info("Nothing was selected.")
    dialog.Destroy()
Ejemplo n.º 7
0
    def getTeamSeasonHtml(self):
        html = INVALID_STRING
        if cmp(self._htmlWebSite, INVALID_STRING) == 0:
            print "htmlWebSite has not been initialized yet"
        else:
            #If we have already synced the data we need to fetch the html from local instead of reloading the website again
            pathNeed2Test = CURRENT_PATH + self._Season0 + self._Season1 + '/' + self._Team_id
            print "Constructing path as ", pathNeed2Test
            self._dataStoredPath = pathNeed2Test
            util.mkdir(pathNeed2Test)

            htmlFile = pathNeed2Test + '/' + self._GameType + '.html'
            self._seasonDataHtmlFile = htmlFile
            print "Check if html file exist or not ", htmlFile

            if os.path.isfile(htmlFile):
                print "html file exists, open the file, read it and return the string"
                html = util.openFile(htmlFile)

                #print html
            else:
                print "html file does not exist, now loading the webpage from network"
                html = util.getHtmlFromUrl(self._htmlWebSite)

                if cmp(html, INVALID_STRING) != 0:
                    util.saveFile(htmlFile, html)

                return html

        return html
Ejemplo n.º 8
0
    def getTeamSeasonHtml(self):
        html = INVALID_STRING
        if cmp(self._htmlWebSite, INVALID_STRING) == 0:
            print "htmlWebSite has not been initialized yet"
        else:
            #If we have already synced the data we need to fetch the html from local instead of reloading the website again
            pathNeed2Test = CURRENT_PATH + self._Season0 + self._Season1 + '/' + self._Team_id
            print "Constructing path as ", pathNeed2Test
            self._dataStoredPath = pathNeed2Test
            util.mkdir(pathNeed2Test)

            htmlFile = pathNeed2Test + '/' + self._GameType + '.html'
            self._seasonDataHtmlFile = htmlFile
            print "Check if html file exist or not ", htmlFile

            if os.path.isfile(htmlFile):
                print "html file exists, open the file, read it and return the string"
                html = util.openFile(htmlFile)

                #print html
            else:
                print "html file does not exist, now loading the webpage from network"
                html = util.getHtmlFromUrl(self._htmlWebSite)

                if cmp(html, INVALID_STRING)!=0:
                    util.saveFile(htmlFile,html)

                return html


        return html
Ejemplo n.º 9
0
def onCreateNewFile(event):
    """called to handle 'create new file' request"""
    logging.debug("Starting")
    frame = util.getMainFrame()
    filters = "PVS files (*" + PVS_EXTENSION + ")|*" + PVS_EXTENSION
    dialog = wx.FileDialog(frame,
                           "Create a new PVS file",
                           wildcard=filters,
                           style=wx.SAVE | wx.OVERWRITE_PROMPT)
    if dialog.ShowModal() == wx.ID_OK:
        fullname = dialog.GetPath()
        if not fullname.endswith(PVS_EXTENSION):
            fullname = fullname + PVS_EXTENSION
        logging.info("Creating new file %s", fullname)
        util.openFile(fullname)
    else:
        logging.info("Nothing was selected.")
    dialog.Destroy()
Ejemplo n.º 10
0
def openImage(file_path=None):
    # Open Image
    file_path = openFile() if not file_path else file_path
    img = cv.imread(file_path,1)

    # Image can be resized to a standard size to speed up processing.
    c = 1000.0/img.shape[0]
    x = int(img.shape[0] * c)
    y = int(img.shape[1] * c)
    img = cv.resize(img, (y,x))

    return img
Ejemplo n.º 11
0
def openImage():
    # Open Image
    file_path = openFile()
    img = cv2.imread(file_path,1)

    # Image can be resized to a standard size to speed up processing.
    c = 1000.0/img.shape[0]
    x = int(img.shape[0] * c)
    y = int(img.shape[1] * c)
    img = cv2.resize(img, (y,x))

    return img
Ejemplo n.º 12
0
    def getSingleGameHtml(self, singleGameLink):
        singleGameUrl = 'http://stat-nba.com/' + singleGameLink
        singleGameHtmlFileName = re.sub('\/', '_', singleGameLink)
        print singleGameHtmlFileName
        singleGameHtmlFilePath = self._dataStoredPath + '/' + singleGameHtmlFileName
        print singleGameHtmlFilePath

        singleGameHtml = INVALID_STRING
        if os.path.isfile(singleGameHtmlFilePath):
            #If html file exist, read it and return the html content
            print singleGameHtmlFilePath + " exist, open the file and read it"
            singleGameHtml = util.openFile(singleGameHtmlFilePath)
        else:
            print singleGameHtmlFilePath + " doesn't exist, load the webpage"
            singleGameHtml = util.getHtmlFromUrl(singleGameUrl)
            util.saveFile(singleGameHtmlFilePath, singleGameHtml)
        return singleGameHtml
Ejemplo n.º 13
0
    def getSingleGameHtml(self, singleGameLink):
        singleGameUrl = 'http://stat-nba.com/'+singleGameLink
        singleGameHtmlFileName = re.sub('\/', '_', singleGameLink)
        print singleGameHtmlFileName
        singleGameHtmlFilePath = self._dataStoredPath + '/' + singleGameHtmlFileName
        print singleGameHtmlFilePath

        singleGameHtml = INVALID_STRING
        if os.path.isfile(singleGameHtmlFilePath):
            #If html file exist, read it and return the html content
            print singleGameHtmlFilePath+ " exist, open the file and read it"
            singleGameHtml = util.openFile(singleGameHtmlFilePath)
        else:
            print singleGameHtmlFilePath + " doesn't exist, load the webpage"
            singleGameHtml = util.getHtmlFromUrl(singleGameUrl)
            util.saveFile(singleGameHtmlFilePath, singleGameHtml)
        return  singleGameHtml
Ejemplo n.º 14
0
import knn
import util

test = knn.KNN()

data = util.openFile("data/iris.csv")

print(test.knnRun(data, 5))
Ejemplo n.º 15
0
 def OnDropFiles(self, x, y, fullnames):
     logging.debug("These files were dropped: %s", fullnames)
     for fullname in fullnames:
         fileExtension = os.path.splitext(fullname)[1]
         if fileExtension == PVS_EXTENSION:
             util.openFile(fullname)