lundi 13 février 2017

looking for design pattern to load packages and execute them with authentication

I'm trying to build an architecture as that:

Main.py

#authenticate ( with 
#load packages form a directory
#execute the package from another(without

Pacakage1.Py

execute some code with already authentication credential

To be more specific , I'm using tweepy library.(to tweet on twitter)

main.py

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)

#-----load package dynamically
#-----execute the script and send the credential

package1.py

def play(apiCredential)
#---do something
#
apiCredential.update_status("someText)

My goal is not to authenticate in each package, Just want once in the main.

Really appreciate the help.

Thanks.

Aucun commentaire:

Enregistrer un commentaire