anilgulecha / misc Goto Github PK
View Code? Open in Web Editor NEWMiscellaneous scripts and stuff
Home Page: http://www.gulecha.org
Miscellaneous scripts and stuff
Home Page: http://www.gulecha.org
If you have a sshMenu config file with a multiple nested menu, the program not work correctly.
I fixed the program modifying the method get_sshmenuconfig() with the follow (for change search for stackMenuIndex):
'''
def get_sshmenuconfig():
if not os.path.exists(_SSHMENU_FILE):
return []
hostlist=open(_SSHMENU_FILE,"r").read()
lines = hostlist.split("\n")
lines.remove("items: ") #get rid of the first instance
app_list = []
smflag=0 # Flag to ignore submenu title items
smtitle="" # To hold the title while searching for parameters
smparams="" # To hold parameters values
stackMenuIndex = []
try:
for line in lines:
if re.search("title:",line):
if smflag == 1:
smtitle=line.split(":", 1)[1]
continue
smflag=1
smtitle=line.split(":", 1)[1]
elif re.search("sshparams:",line):
smparams=line.split(":", 1)[1]
smflag=2
elif re.search("items:",line):
app_list.append({
'name': 'FOLDER',
'cmd': "SSHmenu",
'args':"",
})
#lastmenuindex = len(app_list) - 1
stackMenuIndex.append(len(app_list) - 1)
elif re.search("type: menu",line):
if smflag == 1:
#app_list[lastmenuindex]["cmd"] = smtitle
app_list[stackMenuIndex.pop()]["cmd"] = smtitle
app_list.append({
'name': 'FOLDER',
'cmd': "",
'args':"",
})
smflag = 0
if smflag == 2:
arglist = ("-x ssh " + smparams).split(" ")
for a in arglist:
if a == "":
arglist.remove("")
app_list.append({
'name': smtitle,
'cmd': 'gnome-terminal',
'args': arglist,
})
smflag=0
return app_list
except:
print "error in line:" + line
return []
'''
Bye
dmd@rossum:~$ sshplus.py
Traceback (most recent call last):
File "/usr/local/bin/sshplus.py", line 264, in <module>
appmenu = build_menu()
File "/usr/local/bin/sshplus.py", line 229, in build_menu
app_list2 = get_sshmenuconfig()
File "/usr/local/bin/sshplus.py", line 127, in get_sshmenuconfig
lines.remove("items: ") #get rid of the first instance
ValueError: list.remove(x): x not in list
dmd@rossum:~$ cat .sshplus
up|gnome-terminal|-x ssh up
ubupci|gnome-terminal|-x ssh imt@ubupci
lumen|gnome-terminal|-x ssh [email protected]
What am I doing wrong here?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.