'Execute one of multiple custom python functions via Bash

Set-up

I have a bash file bash_test.sh which looks like,

# !/bin/bash

python /my_path/process_orders.py

where process_orders.py looks like,

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 10 15:25:57 2022

import os

path = ('/my_path')

os.chdir(path + '/order_management/custom_functions')
from new_orders_to_gsheet import new_orders_to_gsheet
from parse_to_books import parse_to_books
from parse_to_supplier import parse_to_supplier
from send_banktransfer_instructions import send_banktransfer_instructions

os.chdir(path + '/order_management/order_shipment')
from fulfill_orders import parse_tracking_codes

os.chdir(path + '/stock_management')
from inventory_sales_90_days import check_inventory_sales
 
#-----------------------------------------------------------------------------#
# CUSTOM FUNCTIONS
#-----------------------------------------------------------------------------#
  
# obtain new orders from shop and make entry in gsheet
new_orders_to_gsheet()
         
# insert new orders into e-boekhouden and note this in gsheet 
parse_to_books()
 
# place orders at supplier and note this in gsheet 
parse_to_supplier()

# send bank transfer instructions 
send_banktransfer_instructions()

# set orders shipped in shopify
parse_tracking_codes()

# check inventory sales past 30 days
check_inventory_sales()

Needed

Currently, bash_test.sh would execute all custom functions in process_orders.py.

However, I want to ONLY execute new_orders_to_gsheet().

How do I do this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source