Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Help with an error

If you have a question or need help, this is the place to be.
Post Reply
molitar
Experienced User
Posts: 209
Joined: Fri Sep 11, 2009 6:44 am

Help with an error

Post by molitar »

I have a piece of code to split text and it has worked for a long time now all of a sudden it has stopped functioning. Maybe a Windows Update broke it I do not know but I really need someones help with this issue.

Traceback (most recent call last):
Python script "38", line 31, in <module>
secArray = elaps.split(':')
AttributeError: 'NoneType' object has no attribute 'split'

Code: Select all

import re

mpc = eg.WindowMatcher(u'mpc-hc.exe', None, u'MediaPlayerClassicW', None, None, None, True, 0.0, 0)
hWnd = mpc()

if len(hWnd) > 0:
    from eg.WinApi import GetWindowText
    title = GetWindowText(hWnd[0])
    if re.search(".mkv",title,re.I):
        title = title.split(".mkv")[0]
    elif re.search(".mp4",title,re.I):
        title = title.split(".mp4")[0]
    elif re.search(".avi",title,re.I):
        title = title.split(".avi")[0]
    elif re.search(".ogm",title,re.I):
        title = title.split(".ogm") [0]
    else:
        title = title.split(".")[0]
        
elaps, rem, total = eg.plugins.MediaPlayerClassic.GetTimes()
#print "elaps, rem, total =",elaps, rem, total

x = 1

while x < 4:

    if elaps != "00:00:00":
        if eg.globals.WindowsState == "Fullscreen": howManyBars = 100
        if eg.globals.WindowsState != "Fullscreen": howManyBars = 100

        secArray = elaps.split(':')
        secArrayTotal = total.split(':')
       
        secondsTotal = int(secArrayTotal[0])*(3600)+int(secArrayTotal[1])*(60)+int(secArrayTotal[2])
        secondsElapsed = int(secArray[0])*(3600)+int(secArray[1])*(60)+int(secArray[2])
       
        percent = (1.0*secondsElapsed)/(secondsTotal)*100
        percent = int(round(percent))
        bars = (percent * howManyBars)/100

        #print "percent =",percent
        #print "bars =",bars
       
        osd = title + "\n \n" + "[ " + "|" * bars + " " * (howManyBars - bars) + " ]" + "\n" + " "*30 + elaps + " / " + total

        if eg.globals.WindowsState <> "Fullscreen":
            eg.plugins.EventGhost.ShowOSD(osd, u'0;-40;0;0;0;700;0;0;0;0;3;2;1;49;Arial', (0, 255, 255), (0, 0, 0), 4, (0, 0), 1, 1.0, False)
        else:
            eg.plugins.EventGhost.ShowOSD(osd, u'0;-40;0;0;0;700;0;0;0;0;3;2;1;49;Arial', (0, 255, 255), (0, 0, 0), 4, (0, 0), 0, 1.0, False)
    eg.Wait(0.8)
    #print x
    x += 1
Dragon470
Experienced User
Posts: 205
Joined: Thu Feb 10, 2011 2:16 am

Re: Help with an error

Post by Dragon470 »

I just tried to make a script to split a message from the google voice plugin, and am getting the same error. AttributeError: 'NoneType' object has no attribute 'split'. I also updated eg when I noticed the error. The error still is there. Have you or anyone figured out why this is, or more importantly how to fix it?
molitar
Experienced User
Posts: 209
Joined: Fri Sep 11, 2009 6:44 am

Re: Help with an error

Post by molitar »

Found the problem to be for some reason the result was not passing so it could not split the name. I uninstalled latest window updates at time it happened and rebooted and everything was again working fine so maybe a windows update caused this to happen.
Post Reply