create account

Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python by steempytutorials

View this thread on: hive.blogpeakd.comecency.com
· @steempytutorials · (edited)
$35.65
Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python
<center>![steem-python.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515886103/kmzfcpvtzuwhvqhgpyjp.png)</center>

This tutorial is part of a series where different aspects of programming with `steem-python` are explained. Links to the other tutorials can be found below. This part is a direct continuation on [Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots](https://steemit.com/utopian-io/@steempytutorials/part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots) where you learned how to directly post an article to the Steem blockchain. This tutorial will expand on this by explaining how to schedule your post on certain times and use a variable vote on your own article.

---

#### What will I learn

- How to schedule your posts
- How to upvote a post with a variable weight

#### Requirements

- Python 3.6
- `steem-python`

#### Difficulty

- Basic

---

### Tutorial

#### Set up
Start by downloading all the files from [github](https://github.com/amosbastian/steempy-tutorials/tree/master/part_7). There are a total of 3 files, `post.txt` is used to store the body of the post, `schedule.json` is used to configure the schedule for the posts and can be altered even when the application is running and `scheduler.py` is the application which will run 24/7.

The application works by loading schedule.json into memory every hour. It then checks if a post is scheduled at that hour and posts this to the blockchain. The post is also upvoted for the set upvote weight. To prevent reposts the submitted post is removed from the schedule and the file is updated to the hard drive.




#### How to schedule your posts
In `schedule.json` you can add a dict containing the data needed to schedule the post. The key itself is the time in hours when the post has to be submitted.  Further there is a title, upvote_weight, tags and a filename to the body of the post.
```
  "13": {
    "title": "Testing scheduler",
    "upvote_weight": 80,
    "tags": "bot test programming python",
    "filename": "post.txt"
  }
```

**Note:** The application is put to sleep for 60 seconds each cycle to preserve CPU resources.

#### How to upvote a post with a variable weight?
In the previous tutorial we submitted the post directly to the blockchain with `self_vote` set to `True`. This automatically upvotes the post but also always upvotes the post for 100%. Instead setting `self_vote` to  `False` allows for a manual upvote with a variable upvote weight.

```
def post(self,
             title,
             body,
             author,
             permlink=None,
             reply_identifier=None,
             json_metadata=None,
             comment_options=None,
             community=None,
             tags=None,
             beneficiaries=None,
             self_vote=False):
```
Calling the post function to submit the post then looks like:

`steem.post(title, body, author, permlink, None, None, None, None, tags, None, False)`

The vote function has the following structure, where the identifier is made up by the author and the permlink we created (explained in the previous tutorial).
```
def vote(self,
             identifier,
             weight,
             account=None):
```

Manually upvoting the post for upvote_weight then looks like:
```
steem.vote('@{}/{}'.format(author,permlink), upvote_weight, author)
```


#### Running the code
Configure the `author` variable to your own account, alter` post.txt` with the post you want to post and set its meta data in `schedule.json`, including the time at which it has to be posted.

> python scheduler.py
Submitted post
Removed entry from schedule
Saved file to harddrive

![Screenshot 2018-01-18 12.03.34.png](https://steemitimages.com/DQmWgW1JFrFZhf4qRj88QwmfYYWchvB1XtzykuZ9i4K4Tzw/Screenshot%202018-01-18%2012.03.34.png)


#### Curriculum
- [Part 0: How To Install Steem-python, The Official Steem Library For Python](https://utopian.io/utopian-io/@amosbastian/how-to-install-steem-python-the-official-steem-library-for-python)
- [Part 1: How To Configure The Steempy CLI Wallet And Upvote An Article With Steem-Python](https://utopian.io/utopian-io/@steempytutorials/part-1-how-to-configure-the-steempy-cli-wallet-and-upvote-an-article-with-steem-python)
- [Part 2: How To Stream And Filter The Blockchain Using Steem-Python](https://steemit.com/utopian-io/@steempytutorials/part-2-how-to-stream-and-filter-the-blockchain-using-steem-python)
- [Part 3: Creating A Dynamic Upvote Bot That Runs 24/7](https://steemit.com/utopian-io/@steempytutorials/part-3-creating-a-dynamic-upvote-bot-that-runs-24-7-first-weekly-challenge-3-steem-prize-pool)
- [Part 4: How To Follow A Voting Trail Using Steem-Python](https://steemit.com/utopian-io/@steempytutorials/part-4-how-to-follow-a-voting-trail-using-steem-python)
- [Part 5: Post An Article Directly To The Steem Blockchain And Automatically Buy Upvotes From Upvote Bots](https://steemit.com/utopian-io/@steempytutorials/part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots)
- [Part 6: How To Automatically Reply To Mentions Using Steem-Python](https://steemit.com/utopian-io/@steempytutorials/part-6-how-to-automatically-reply-to-mentions-using-steem-python)

#### Credits
This tutorial was written by @juliank in conjunction with @amosbastian

---

The code for this tutorial can be found on [GitHub](https://github.com/amosbastian/steempy-tutorials/tree/master/part_7)!

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@steempytutorials/part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorsteempytutorials
permlinkpart-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python
categoryutopian-io
json_metadata{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":84843862,"name":"steem-python","full_name":"steemit/steem-python","html_url":"https://github.com/steemit/steem-python","fork":false,"owner":{"login":"steemit"}},"pullRequests":[],"platform":"github","type":"tutorials","tags":["utopian-io","steemdev","programming","python","tutorial"],"users":["steempytutorials","amosbastian","juliank"],"links":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1515886103/kmzfcpvtzuwhvqhgpyjp.png","https://steemit.com/utopian-io/@steempytutorials/part-5-post-an-article-directly-to-the-steem-blockchain-and-automatically-buy-upvotes-from-upvote-bots","https://github.com/amosbastian/steempy-tutorials/tree/master/part_7","https://steemitimages.com/DQmWgW1JFrFZhf4qRj88QwmfYYWchvB1XtzykuZ9i4K4Tzw/Screenshot%202018-01-18%2012.03.34.png","https://utopian.io/utopian-io/@amosbastian/how-to-install-steem-python-the-official-steem-library-for-python","https://utopian.io/utopian-io/@steempytutorials/part-1-how-to-configure-the-steempy-cli-wallet-and-upvote-an-article-with-steem-python","https://steemit.com/utopian-io/@steempytutorials/part-2-how-to-stream-and-filter-the-blockchain-using-steem-python","https://steemit.com/utopian-io/@steempytutorials/part-3-creating-a-dynamic-upvote-bot-that-runs-24-7-first-weekly-challenge-3-steem-prize-pool","https://steemit.com/utopian-io/@steempytutorials/part-4-how-to-follow-a-voting-trail-using-steem-python","https://steemit.com/utopian-io/@steempytutorials/part-6-how-to-automatically-reply-to-mentions-using-steem-python"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1515886103/kmzfcpvtzuwhvqhgpyjp.png","https://steemitimages.com/DQmWgW1JFrFZhf4qRj88QwmfYYWchvB1XtzykuZ9i4K4Tzw/Screenshot%202018-01-18%2012.03.34.png"],"moderator":{"account":"shreyasgune","time":"2018-01-18T17:30:53.950Z","reviewed":true,"pending":false,"flagged":false}}
created2018-01-18 17:05:18
last_update2018-01-18 17:30:54
depth0
children11
last_payout2018-01-25 17:05:18
cashout_time1969-12-31 23:59:59
total_payout_value28.320 HBD
curator_payout_value7.330 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,796
author_reputation31,094,047,689,691
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries
0.
accountutopian.pay
weight2,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,437,650
net_rshares5,448,461,098,600
author_curate_reward""
vote details (24)
@arkhan007 ·
one of the best language for computer programmers to work on
properties (22)
authorarkhan007
permlinkre-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180118t172817958z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-18 17:28:21
last_update2018-01-18 17:28:21
depth1
children0
last_payout2018-01-25 17:28:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length60
author_reputation13,366,118
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,442,186
net_rshares0
@dediayomi ·
Thank you sharing....
properties (22)
authordediayomi
permlinkre-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180118t224733488z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-18 22:47:39
last_update2018-01-18 22:47:39
depth1
children0
last_payout2018-01-25 22:47:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length21
author_reputation216,464,964,461
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,494,614
net_rshares0
@emrebeyler · (edited)
$0.16
Great!

Can you also consider writing a tutorial about how to create posts with beneficiaries?
👍  ,
properties (23)
authoremrebeyler
permlinkre-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180118t185255265z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-18 18:52:54
last_update2018-01-18 18:53:33
depth1
children1
last_payout2018-01-25 18:52:54
cashout_time1969-12-31 23:59:59
total_payout_value0.125 HBD
curator_payout_value0.034 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length94
author_reputation448,528,959,341,273
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,457,960
net_rshares19,908,238,604
author_curate_reward""
vote details (2)
@juliank ·
$0.02
Surely can, will look into this as I have never used this before. Thanks for the tip!
👍  
properties (23)
authorjuliank
permlinkre-emrebeyler-re-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180118t211938218z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-18 21:19:39
last_update2018-01-18 21:19:39
depth2
children0
last_payout2018-01-25 21:19:39
cashout_time1969-12-31 23:59:59
total_payout_value0.021 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length85
author_reputation117,823,071,447,502
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,481,907
net_rshares2,968,149,406
author_curate_reward""
vote details (1)
@marshel ·
I like your post as succesful as always
👍  
properties (23)
authormarshel
permlinkre-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180118t171717556z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-18 17:17:21
last_update2018-01-18 17:17:21
depth1
children0
last_payout2018-01-25 17:17:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length39
author_reputation97,865,393,404
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,440,020
net_rshares614,473,942
author_curate_reward""
vote details (1)
@maxg ·
$0.34
Cool!

---

Instead of keeping the timing logic inside the python script you could use a tool like [at](https://tecadmin.net/one-time-task-scheduling-using-at-commad-in-linux/) on Linux and Mac. Then you wouldn't have to update the  JSON each time you want to schedule a new script or worry that a failed earlier post would impact a later post.
```
> echo 'python post.py first_post.txt' | at 9:00AM
> echo 'python post.py second_post.txt' | at 11:00AM
```
👍  
properties (23)
authormaxg
permlinkre-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180119t035902140z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://tecadmin.net/one-time-task-scheduling-using-at-commad-in-linux/"],"app":"steemit/0.1"}
created2018-01-19 03:59:03
last_update2018-01-19 03:59:03
depth1
children2
last_payout2018-01-26 03:59:03
cashout_time1969-12-31 23:59:59
total_payout_value0.258 HBD
curator_payout_value0.083 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length456
author_reputation5,859,582,764,121
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,538,981
net_rshares41,198,382,850
author_curate_reward""
vote details (1)
@emrebeyler ·
$0.03
wow, at command looks very good.
👍  
properties (23)
authoremrebeyler
permlinkre-maxg-re-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180119t063436642z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-19 06:34:36
last_update2018-01-19 06:34:36
depth2
children0
last_payout2018-01-26 06:34:36
cashout_time1969-12-31 23:59:59
total_payout_value0.026 HBD
curator_payout_value0.008 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length32
author_reputation448,528,959,341,273
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,560,465
net_rshares4,510,579,716
author_curate_reward""
vote details (1)
@juliank ·
Awesome, thanks I will have a look at it
properties (22)
authorjuliank
permlinkre-maxg-re-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180119t072754948z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-19 07:27:54
last_update2018-01-19 07:27:54
depth2
children0
last_payout2018-01-26 07:27:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length40
author_reputation117,823,071,447,502
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,567,723
net_rshares0
@shreyasgune ·
$1.06
Thank you for the contribution. It has been approved.

You can contact us on [Discord](https://discord.gg/uTyJkNm).
**[[utopian-moderator]](https://utopian.io/moderators)**
👍  ,
properties (23)
authorshreyasgune
permlinkre-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180118t173100229z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-18 17:31:03
last_update2018-01-18 17:31:03
depth1
children1
last_payout2018-01-25 17:31:03
cashout_time1969-12-31 23:59:59
total_payout_value0.933 HBD
curator_payout_value0.126 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length172
author_reputation4,924,803,411,962
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,442,689
net_rshares128,668,711,382
author_curate_reward""
vote details (2)
@juliank ·
Appreciated as always :D
properties (22)
authorjuliank
permlinkre-shreyasgune-re-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180118t212001237z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-18 21:20:00
last_update2018-01-18 21:20:00
depth2
children0
last_payout2018-01-25 21:20:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length24
author_reputation117,823,071,447,502
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,481,979
net_rshares0
@utopian-io ·
### Hey @steempytutorials I am @utopian-io. I have just upvoted you!
#### Achievements
- You have less than 500 followers. Just gave you a gift to help you succeed!
- Seems like you contribute quite often. AMAZING!
#### Suggestions
- Contribute more often to get higher and higher rewards. I wish to see you often!
- Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!
#### Get Noticed!
- Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!
#### Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a>
- Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a>

[![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](https://steemit.com/~witnesses)

**Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
properties (22)
authorutopian-io
permlinkre-steempytutorials-part-7-how-to-schedule-posts-and-manually-upvote-posts-for-a-variable-voting-weight-with-steem-python-20180119t190036834z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-19 19:00:36
last_update2018-01-19 19:00:36
depth1
children0
last_payout2018-01-26 19:00:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,514
author_reputation152,955,367,999,756
root_title"Part 7: How To Schedule Posts And Manually Upvote Posts For A Variable Voting Weight With Steem-Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,688,642
net_rshares0