Skip to content

Commit

Permalink
Merge pull request #3 from pavobravo11/revert-2-main-manuel
Browse files Browse the repository at this point in the history
Revert "Finalize tweepy stuff"
  • Loading branch information
mschoenlaub authored Apr 23, 2022
2 parents 98566b6 + b0beb94 commit 83df0dd
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 46 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ jobs:
- run: python -V
- run: poetry run python -V
- run: poetry run python ./AQScripts.py
- run: poetry run python ./tweetImageOnly.py
env:
CONSUMER_KEY: ${{ secrets.CONSUMER_KEY }}
CONSUMER_SECRET: ${{ secrets.CONSUMER_SECRET }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }}
- run: poetry run python ./HistoricalGraph.py
- name: Setup markdown-styles
run: npm install -g markdown-styles
Expand Down
1 change: 0 additions & 1 deletion AQScripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def runner():
# fig.show()

fig.write_json("input/aiqmap.json")
fig.write_image("input/aiqmap.png")


# This is a support function used to get the json
Expand Down
18 changes: 1 addition & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ geopy = "^2.2.0"
Shapely = "^1.8.1"
requests = "^2.27.1"
tweepy = "^4.8.0"
kaleido = "0.2.1"

[tool.poetry.dev-dependencies]
jupyterlab = "^3.2.9"
Expand Down
52 changes: 31 additions & 21 deletions tweetImageOnly.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
import os

import tweepy
import configparser
import os

#def publish_tweet():
dirname = os.path.dirname(__file__)

consumer_key = os.environ["CONSUMER_KEY"]
consumer_secret = os.environ["CONSUMER_SECRET"]
access_token = os.environ["ACCESS_TOKEN"]
access_token_secret = os.environ["ACCESS_TOKEN_SECRET"]

auth = tweepy.OAuth1UserHandler(
consumer_key=consumer_key, consumer_secret=consumer_secret,
access_token=access_token,
access_token_secret=access_token_secret
)

# open config file
config_init_filename = os.path.join(dirname, 'config.ini')
config_parser = configparser.ConfigParser()
config_parser.readfp(open(config_init_filename))
# read tweeter credentials
consumer_key = config_parser['tweeter']['consumer_key']
consumer_secret = config_parser['tweeter']['consumer_secret']
access_token = config_parser['tweeter']['access_token']
access_token_secret = config_parser['tweeter']['access_token_secret']
bearer_token = config_parser['tweeter']['bearer_token']

# authorization of consumer key and consumer secret
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)

# set access to user's access key and access secret
auth.set_access_token(access_token, access_token_secret)

# calling the api
api = tweepy.API(auth)
client = tweepy.Client(consumer_key=consumer_key, consumer_secret=consumer_secret,
access_token=access_token,
access_token_secret=access_token_secret)

client = tweepy.Client(bearer_token=bearer_token,
access_token=access_token,
access_token_secret=access_token_secret,
consumer_key=consumer_key,
consumer_secret=consumer_secret)

# the name of the media file
graph_filename = os.path.join(dirname, "input/aiqmap.png")

graph_filename = os.path.join(dirname, 'newplot.png')
# upload the file
media = api.media_upload(graph_filename)

# printing the information
print("The media ID is : " + media.media_id_string)
print("The size of the file is : " + str(media.size) + " bytes")
client.create_tweet(media_ids=[media.media_id_string])
client.create_tweet(media_ids= [media.media_id_string])

0 comments on commit 83df0dd

Please sign in to comment.