Open Jbithell opened 8 years ago
Yes - BTW, you've got some wrapped version of Words, right? What's it called again?
Yes I do - it's sapiensoptio.com - and the intention is to move it to this script.
What I did was just provide the argument when I called it. The welcome menu does not show up when providing arguments. I made a prayer memorizing program years ago in python and that mechanism worked fine. I actually parsed the argument list and did a single word at a time for example:
words pater words noster words qui words es
If the user selected more than one word for grammar.
Here is a link to the python code if you are interested.
def btnShowGrammarClick(self, event): # wxGlade: MyFrame.
contentsOfSelection = self.txtDisplayPrayer.GetStringSelection()
if contentsOfSelection != '':
searchTerms = \
self.Parser.scrubListOfPunctuation(contentsOfSelection.split(' '
))
else:
searchTerms = \
self.Parser.scrubListOfPunctuation(self.txtDisplayPrayer.GetValue().split(' '
))
operatingSystem = platform.system().lower()
runCommandForGrammar = ''
for searchTerm in searchTerms:
if searchTerm != '':
currentDirectory = self.getCurrentFileLocation()
newDirectory = os.path.join(currentDirectory,
'LatinEngines')
if operatingSystem.find('linux') != -1:
newDirectory = os.path.join(newDirectory, 'Linux')
runCommandForGrammar = './words'
if operatingSystem.find('windows') != -1\
or operatingSystem.find('microsoft') != -1:
newDirectory = os.path.join(newDirectory, 'Windows')
runCommandForGrammar = 'words.exe'
if operatingSystem.find('darwin') != -1:
newDirectory.path.join(newDirectory, 'Linux')
runCommandForGrammar = './words'
os.chdir(newDirectory)
try:
myOutput = subprocess.Popen([runCommandForGrammar,
self.Parser.unicodeToAscii(searchTerm)],
stdout=subprocess.PIPE).communicate()[0]
except:
myOutput = 'An error has occured try again.'
os.chdir(currentDirectory)
self.txtDisplayInfo.SetValue((self.txtDisplayInfo.GetValue()
+ '''
''' + myOutput).strip('\n'))
event.Skip()
btw I had just started learning to program back then and am naturally embarrassed by the code specifically checking for the os on every loop through was wasteful. The program worked/works well enough though. The output was the full grammar.
Is there a simple way to call whitakers-words from a bash script, with parameters passed, and have only the output returned, instead of the welcome menu returned etc.