Fixed indentation and trailing spaces
This commit is contained in:
parent
048d0c386c
commit
877ce3640b
@ -555,7 +555,7 @@ class MenuWin( object ):
|
||||
self.do_image(self.buttonIcon, True)
|
||||
|
||||
def leave_notify(self, applet, event):
|
||||
# Hack for mate-panel-test-applets focus issue (this can be commented)
|
||||
# Hack for mate-panel-test-applets focus issue (this can be commented)
|
||||
if event.state & Gdk.ModifierType.BUTTON1_MASK and applet.state & Gtk.StateType.SELECTED:
|
||||
if event.x >= 0 and event.y >= 0 and event.x < applet.window.get_width() and event.y < applet.window.get_height():
|
||||
self.mainwin.stopHiding()
|
||||
|
@ -356,11 +356,11 @@ class pluginclass( object ):
|
||||
self.panel_position = object_schema.get_int("position") + 1
|
||||
|
||||
def apturl_install(self, widget, pkg_name):
|
||||
if os.path.exists("/usr/bin/apturl"):
|
||||
os.system("/usr/bin/apturl apt://%s &" % pkg_name)
|
||||
else:
|
||||
os.system("xdg-open apt://" + pkg_name + " &")
|
||||
self.mintMenuWin.hide()
|
||||
if os.path.exists("/usr/bin/apturl"):
|
||||
os.system("/usr/bin/apturl apt://%s &" % pkg_name)
|
||||
else:
|
||||
os.system("xdg-open apt://" + pkg_name + " &")
|
||||
self.mintMenuWin.hide()
|
||||
|
||||
def __del__( self ):
|
||||
print u"Applications plugin deleted"
|
||||
|
@ -3,122 +3,12 @@
|
||||
import os
|
||||
import os.path
|
||||
import urllib
|
||||
"""
|
||||
def TestForDir(dirname):
|
||||
if not os.path.exists( os.path.join(os.path.expanduser("~"), dirname ) ):
|
||||
os.makedirs( os.path.join( os.path.expanduser("~"), dirname) )
|
||||
|
||||
def TestForFiles(filename):
|
||||
if not os.path.exists( os.path.join( os.path.expanduser("~"), filename ) ):
|
||||
file = open( os.path.join( os.path.expanduser("~"), filename ),"w")
|
||||
file.close()
|
||||
|
||||
def FileExists(f):
|
||||
return os.path.exists(f)
|
||||
"""
|
||||
|
||||
def GetFilePath(uri):
|
||||
path = urllib.url2pathname(uri) # escape special chars
|
||||
path = path.strip('\r\n\x00') # remove \r\n and NULL
|
||||
path = urllib.url2pathname(uri) # escape special chars
|
||||
path = path.strip('\r\n\x00') # remove \r\n and NULL
|
||||
|
||||
# get the path to file
|
||||
if path.startswith('file://'): # nautilus, rox
|
||||
path = path[7:] # 7 is len('file://')
|
||||
return path
|
||||
|
||||
"""
|
||||
def ParseDesktopFile(DFile):
|
||||
# Get the locale
|
||||
lang = os.getenv("LANG")
|
||||
if lang:
|
||||
langArray = lang.split("_")
|
||||
else:
|
||||
langArray = [ None ]
|
||||
locale = langArray[0] or ""
|
||||
localeName = "Name[" + locale + "]="
|
||||
localeComment = "Comment[" + locale + "]="
|
||||
localeGenericName = "GenericName[" + locale + "]="
|
||||
PlaceName=PlaceComment=PlaceExec=PlaceIconName=GenericName=TerminalName=""
|
||||
FileData = []
|
||||
if FileExists(GetFilePath(DFile))==True:
|
||||
parseData = False
|
||||
openfile = open(GetFilePath(DFile), 'r')
|
||||
datalist = openfile.readlines()
|
||||
openfile.close()
|
||||
for i in datalist:
|
||||
i = i.strip('\r\n\x00')
|
||||
if len(i) != 0:
|
||||
if i[0] == "[" and i[-1] == "]":
|
||||
parseData = "[Desktop Entry]" == i
|
||||
elif parseData:
|
||||
if i[0:5] == "Name=":
|
||||
PlaceName = i[5:]
|
||||
elif i[0:9] == localeName:
|
||||
PlaceName = i[9:]
|
||||
elif i[0:8] == "Comment=":
|
||||
PlaceComment = i[8:]
|
||||
elif i[0:12] == localeComment:
|
||||
PlaceComment = i[12:]
|
||||
elif i[0:5] == "Exec=":
|
||||
PlaceExec = i[5:]
|
||||
elif i[0:5] == "Icon=":
|
||||
PlaceIconName = i[5:]
|
||||
elif i[0:12] == "GenericName=":
|
||||
GenericName = i[12:]
|
||||
elif i[0:16] == localeGenericName:
|
||||
GenericName = i[16:]
|
||||
elif i[0:9] == "Terminal=":
|
||||
TerminalName = i[9:]
|
||||
|
||||
FileData.append(PlaceName)
|
||||
FileData.append(PlaceComment)
|
||||
FileData.append(PlaceExec)
|
||||
FileData.append(PlaceIconName)
|
||||
FileData.append(GenericName)
|
||||
FileData.append(TerminalName)
|
||||
return FileData
|
||||
|
||||
return None
|
||||
|
||||
def WriteListFile(ListToAdd,ItemToAdd,mode):
|
||||
|
||||
RecentapplicationsFile = open (os.path.join(os.path.expanduser("~"), ListToAdd),"r")
|
||||
RecentapplicationsList = RecentapplicationsFile.readlines()
|
||||
RecentapplicationsList.reverse()
|
||||
RecentapplicationsFile.close()
|
||||
|
||||
if RecentapplicationsList != []:
|
||||
outfile = open (os.path.join(os.path.expanduser("~"), ListToAdd),mode)
|
||||
outfile.write(ItemToAdd+"\n")
|
||||
outfile.close()
|
||||
else:
|
||||
outfile = open (os.path.join(os.path.expanduser("~"), ListToAdd),mode)
|
||||
outfile.write(ItemToAdd+"\n")
|
||||
outfile.close()
|
||||
|
||||
|
||||
def EditDesktopFile(DroppedFile,FileData,ListToAdd):
|
||||
fileHandle = open ( DroppedFile , 'w' )
|
||||
fileHandle.write ( '[Desktop Entry]\nEncoding=UTF-8\n' )
|
||||
fileHandle.write ( 'Name='+FileData[0]+'\n')
|
||||
fileHandle.write ( 'Comment='+FileData[1]+'\n')
|
||||
fileHandle.write ( 'Exec='+FileData[2]+'\n')
|
||||
fileHandle.write ( 'Icon='+FileData[3]+'\n')
|
||||
fileHandle.write ( 'GenericName='+FileData[4]+'\n')
|
||||
fileHandle.write ( 'Terminal='+FileData[5]+'\n')
|
||||
fileHandle.close()
|
||||
|
||||
def WriteDesktopFile(DroppedFile,FileData,ListToAdd):
|
||||
fileHandle = open ( DroppedFile , 'w' )
|
||||
fileHandle.write ( '[Desktop Entry]\nEncoding=UTF-8\n' )
|
||||
fileHandle.write ( 'Name='+FileData[0]+'\n')
|
||||
fileHandle.write ( 'Comment='+FileData[1]+'\n')
|
||||
fileHandle.write ( 'Exec='+FileData[2]+'\n')
|
||||
fileHandle.write ( 'Icon='+FileData[3]+'\n')
|
||||
fileHandle.write ( 'GenericName='+FileData[4]+'\n')
|
||||
fileHandle.write ( 'Terminal='+FileData[5]+'\n')
|
||||
fileHandle.close()
|
||||
|
||||
WriteListFile(ListToAdd,DroppedFile,"a")
|
||||
print "Added to places.list"
|
||||
"""
|
||||
# get the path to file
|
||||
if path.startswith('file://'): # nautilus, rox
|
||||
path = path[7:] # 7 is len('file://')
|
||||
return path
|
||||
|
@ -3,45 +3,45 @@
|
||||
import os
|
||||
|
||||
def RemoveArgs(Execline):
|
||||
NewExecline = []
|
||||
Specials=["\"%c\"", "%f","%F","%u","%U","%d","%D","%n","%N","%i","%c","%k","%v","%m","%M", "-caption", "/bin/sh", "sh", "-c", "STARTED_FROM_MENU=yes"]
|
||||
for elem in Execline:
|
||||
elem = elem.replace("'","")
|
||||
elem = elem.replace("\"", "")
|
||||
if elem not in Specials:
|
||||
print elem
|
||||
NewExecline.append(elem)
|
||||
return NewExecline
|
||||
NewExecline = []
|
||||
Specials=["\"%c\"", "%f","%F","%u","%U","%d","%D","%n","%N","%i","%c","%k","%v","%m","%M", "-caption", "/bin/sh", "sh", "-c", "STARTED_FROM_MENU=yes"]
|
||||
for elem in Execline:
|
||||
elem = elem.replace("'","")
|
||||
elem = elem.replace("\"", "")
|
||||
if elem not in Specials:
|
||||
print elem
|
||||
NewExecline.append(elem)
|
||||
return NewExecline
|
||||
|
||||
# Actually execute the command
|
||||
def Execute( cmd , commandCwd=None):
|
||||
if not commandCwd:
|
||||
cwd = os.path.expanduser( "~" );
|
||||
else:
|
||||
tmpCwd = os.path.expanduser( commandCwd );
|
||||
if (os.path.exists(tmpCwd)):
|
||||
cwd = tmpCwd
|
||||
if not commandCwd:
|
||||
cwd = os.path.expanduser( "~" );
|
||||
else:
|
||||
tmpCwd = os.path.expanduser( commandCwd );
|
||||
if (os.path.exists(tmpCwd)):
|
||||
cwd = tmpCwd
|
||||
|
||||
if isinstance( cmd, str ) or isinstance( cmd, unicode):
|
||||
if (cmd.find("ubiquity") >= 0) or (cmd.find("/home/") >= 0) or (cmd.find("su-to-root") >= 0) or (cmd.find("\"") >= 0):
|
||||
print "running manually..."
|
||||
try:
|
||||
os.chdir(cwd)
|
||||
os.system(cmd + " &")
|
||||
return True
|
||||
except Exception, detail:
|
||||
print detail
|
||||
return False
|
||||
cmd = cmd.split()
|
||||
cmd = RemoveArgs(cmd)
|
||||
if isinstance( cmd, str ) or isinstance( cmd, unicode):
|
||||
if (cmd.find("ubiquity") >= 0) or (cmd.find("/home/") >= 0) or (cmd.find("su-to-root") >= 0) or (cmd.find("\"") >= 0):
|
||||
print "running manually..."
|
||||
try:
|
||||
os.chdir(cwd)
|
||||
os.system(cmd + " &")
|
||||
return True
|
||||
except Exception, detail:
|
||||
print detail
|
||||
return False
|
||||
cmd = cmd.split()
|
||||
cmd = RemoveArgs(cmd)
|
||||
|
||||
try:
|
||||
os.chdir( cwd )
|
||||
string = ' '.join(cmd)
|
||||
string = string + " &"
|
||||
os.system(string)
|
||||
return True
|
||||
except Exception, detail:
|
||||
print detail
|
||||
return False
|
||||
try:
|
||||
os.chdir( cwd )
|
||||
string = ' '.join(cmd)
|
||||
string = string + " &"
|
||||
os.system(string)
|
||||
return True
|
||||
except Exception, detail:
|
||||
print detail
|
||||
return False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user