Python Forum
Make bash call my own Python modules
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make bash call my own Python modules
#1
I have a little homework webpage. I'm trying to automate the production of the webpage each week.

I know very little about this. Wednesday I asked here about importing Python functions that I made. I think I have grasped the concept. I've tested everything in Idle. All the modules work.

In my Python shell, (I use Idle in Ubuntu), everything does what I want.

I first append the paths:


for i in range(0, len(pyPaths)):
sys.path.append(pyPaths[i])
then import the modules:


from makeRBsInlineV1 import makeHTMLrbsNums
from makeCheckboxesInlineV1 import makeHTMLCBs
from makeDropdownboxesInlineV1 import makeDropdownboxes
from createhtmlTableInlineV1 import makeHTMLtable
from makeRBsInlineV2 import makeHTML_RBs
from readLinesTextboxesInlineV1 import readLinesmakeTBs
from makeThankyouPHPInlineV1 import makeThankyouPHP
All these modules return a text string which is a mixture of html tags + my text. It displays nicely in Firefox.

In Idle I just write, for example:

myString = readLinesTextboxesInlineV3()
it asks me a few questions and off it goes. Afterwards, myString is ready to be put in the webpage text string.

However, in bash, I cannot write


myString = readLinesTextboxesInlineV3()
in bash, I cannot write


myString = input('Enter the name of the module you want. ')
and then enter,


readLinesTextboxesInlineV3()
because then myString is just the input text, not the function.

Each week things are different, I may need to run 2 or more of the modules, add the result strings, then write them in the webpage text string in the correct insertion point.

I run this in a


while True:
loop, so I can add strings from various modules.

For any given week, I don't know which module I want to use, so I make them all available.

I have a list of all the modules:

pyFiles = ['makeCheckboxesInlineV1()', 'dropdownboxesInlineV1()', 'createhtmlTableInlineV1()', 'makeRBsInlineV2()', 'readLinesTextboxesInlineV3()', 'makeThankyouPHPInlineV1()']
How do I assign myString to any 1 of the modules above when I run makeWebpage.py in bash?
Reply


Messages In This Thread
Make bash call my own Python modules - by Pedroski55 - Apr-19-2019, 08:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems passing arguments containing spaces to bash script and then on to python kaustin 6 546 Apr-03-2024, 08:26 PM
Last Post: deanhystad
  How to see the date of installation of python modules. newbieAuggie2019 4 1,738 Mar-31-2023, 12:40 PM
Last Post: newbieAuggie2019
  Python modules for accessing the configuration of relevant paths Imago 1 1,438 May-07-2022, 07:28 PM
Last Post: Larz60+
  Call a bash script from within a Python programme Pedroski55 6 2,552 Dec-06-2021, 01:53 PM
Last Post: DeaD_EyE
  Showing and saving the output of a python file run through bash Rim 3 2,568 Oct-06-2021, 10:48 AM
Last Post: gerpark
  Python modules to extract data from a graph? bigmit37 5 22,655 Apr-09-2021, 02:15 PM
Last Post: TysonL
  Where to add own python modules in WinPython? HinterhaeltigesSchlaengelchen 1 2,329 Jan-21-2021, 07:45 PM
Last Post: snippsat
  Including modules in Python using sys.path.append JoeDainton123 1 2,983 Aug-24-2020, 04:51 AM
Last Post: millpond
  How to kill a bash script running as root from a python script? jc_lafleur 4 6,036 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  how to get PID's of linux commands executed through python modules? Manikandan_PS 4 3,115 Mar-12-2020, 07:16 AM
Last Post: Manikandan_PS

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020