This repository has been archived by the owner on Sep 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TweetPlot.py
65 lines (53 loc) · 1.63 KB
/
TweetPlot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import pybamm
import tweepy
import time
import matplotlib.pyplot as plt
import importlib.util
import os
spec1 = importlib.util.spec_from_file_location(
"RandomPlotGenerator.py", "Randomness/RandomPlotGenerator.py"
)
foo1 = importlib.util.module_from_spec(spec1)
spec1.loader.exec_module(foo1)
spec2 = importlib.util.spec_from_file_location(
"Information.py", "InformationModule/Information.py"
)
foo2 = importlib.util.module_from_spec(spec2)
spec2.loader.exec_module(foo2)
CONSUMER_KEY = os.environ.get("CONSUMER_KEY")
CONSUMER_SECRET = os.environ.get("CONSUMER_SECRET")
ACCESS_KEY = os.environ.get("ACCESS_KEY")
ACCESS_SECRET = os.environ.get("ACCESS_SECRET")
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
def tweet_graph():
(
parameter_values,
time_of_png,
parameter_number,
cycle,
solver,
number,
) = foo1.random_plot_generator()
print(time_of_png)
info_string = (
foo2.information(parameter_number, str(cycle) + " * " + str(number), solver)
+ ", at time = "
+ str(time_of_png)
)
# +"with parameter values: " + str(parameter_values)
# # Uncomment to tweet
media = api.media_upload("foo.png")
test_string = "https://github.com/Saransh-cpp/TwitterBot " + info_string
tweet = test_string
api.update_status(status=tweet, media_ids=[media.media_id])
os.remove("foo.png")
plt.clf()
# Simulate tweeting process
while True:
print("Tweeting....")
tweet_graph()
time.sleep(10800)
# Uncomment to run the code only once
# tweet_graph()