diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 44dbb480b5..5454a0bf41 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -30,6 +30,12 @@ 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 diff --git a/AQScripts.py b/AQScripts.py index d4c2ac7094..50bca0e1ef 100755 --- a/AQScripts.py +++ b/AQScripts.py @@ -99,6 +99,7 @@ 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 diff --git a/poetry.lock b/poetry.lock index 18474de8f1..6ccd6776f5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -643,6 +643,14 @@ category = "dev" optional = false python-versions = ">=3.6" +[[package]] +name = "kaleido" +version = "0.2.1" +description = "Static image export for web-based visualization libraries with zero dependencies" +category = "main" +optional = false +python-versions = "*" + [[package]] name = "kiwisolver" version = "1.4.0" @@ -1497,7 +1505,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "~3.10" -content-hash = "375a2c2a647204ec642caa7e332f7005cc1c96614d44f5659898940062f0749a" +content-hash = "7dc4ba8c7fdcaff8abe79d05032fe46b480ae205b317955d72cbee5aa0348b95" [metadata.files] aiohttp = [ @@ -1920,6 +1928,14 @@ jupyterlab-widgets = [ {file = "jupyterlab_widgets-1.1.0-py3-none-any.whl", hash = "sha256:c2a9bd3789f120f64d73268c066ed3b000c56bc1dda217be5cdc43e7b4ebad3f"}, {file = "jupyterlab_widgets-1.1.0.tar.gz", hash = "sha256:d5f41bc1713795385f718d44dcba47e1e1473c6289f28a95aa6b2c0782ee372a"}, ] +kaleido = [ + {file = "kaleido-0.2.1-py2.py3-none-macosx_10_11_x86_64.whl", hash = "sha256:ca6f73e7ff00aaebf2843f73f1d3bacde1930ef5041093fe76b83a15785049a7"}, + {file = "kaleido-0.2.1-py2.py3-none-macosx_11_0_arm64.whl", hash = "sha256:bb9a5d1f710357d5d432ee240ef6658a6d124c3e610935817b4b42da9c787c05"}, + {file = "kaleido-0.2.1-py2.py3-none-manylinux1_x86_64.whl", hash = "sha256:aa21cf1bf1c78f8fa50a9f7d45e1003c387bd3d6fe0a767cfbbf344b95bdc3a8"}, + {file = "kaleido-0.2.1-py2.py3-none-manylinux2014_aarch64.whl", hash = "sha256:845819844c8082c9469d9c17e42621fbf85c2b237ef8a86ec8a8527f98b6512a"}, + {file = "kaleido-0.2.1-py2.py3-none-win32.whl", hash = "sha256:ecc72635860be616c6b7161807a65c0dbd9b90c6437ac96965831e2e24066552"}, + {file = "kaleido-0.2.1-py2.py3-none-win_amd64.whl", hash = "sha256:4670985f28913c2d063c5734d125ecc28e40810141bdb0a46f15b76c1d45f23c"}, +] kiwisolver = [ {file = "kiwisolver-1.4.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:70e7b7a4ebeddef423115ea31857732fc04e0f38dd1e6385e1af05b6164a3d0f"}, {file = "kiwisolver-1.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:384b5076b2c0172003abca9ba8b8c5efcaaffd31616f3f5e0a09dcc34772d012"}, diff --git a/pyproject.toml b/pyproject.toml index b274044667..602af18906 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ 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" diff --git a/tweetImageOnly.py b/tweetImageOnly.py index df089d1862..b22f952ab5 100644 --- a/tweetImageOnly.py +++ b/tweetImageOnly.py @@ -1,42 +1,32 @@ -import tweepy -import configparser import os -#def publish_tweet(): +import tweepy + dirname = os.path.dirname(__file__) -# 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 +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 +) + api = tweepy.API(auth) -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) - +client = tweepy.Client(consumer_key=consumer_key, consumer_secret=consumer_secret, + access_token=access_token, + access_token_secret=access_token_secret) + # the name of the media file -graph_filename = os.path.join(dirname, 'newplot.png') - +graph_filename = os.path.join(dirname, "input/aiqmap.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]) \ No newline at end of file +client.create_tweet(media_ids=[media.media_id_string])