In [ ]:
Product Price

Script to edit prices for products.

In [64]:
import os
import json
from TwitterFollowBot import TwitterBot

In [65]:
brotw = TwitterBot('/home/wcmckee/github/wcmckee-notebook/config.txt')

In [ ]:


In [66]:
prodir = ('/home/wcmckee/sellcoffee/products/')

In [67]:
print (os.listdir(prodir))


['followers.txt', 'coffee', 'crayons', 'port-royalport-royalindex.json', 'MarQuis Black CondomsMarQuis Black Condomsindex.json', 'port-royal', 'MarQuis Black Condoms', 'already-followed.txt', 'following.txt', 'coffeecoffeeindex.json']

In [69]:
pricewhat = input('Product to set price: ')


Product to set price: port-royal

In [70]:
priceset = input('Price to set: ')


Price to set: 456

In [71]:
brotw.send_tweet('Price of ' + pricewhat + 'is ' + priceset)


Out[71]:
{'contributors': None,
 'coordinates': None,
 'created_at': 'Sat Aug 15 11:57:11 +0000 2015',
 'entities': {'hashtags': [], 'symbols': [], 'urls': [], 'user_mentions': []},
 'favorite_count': 0,
 'favorited': False,
 'geo': None,
 'id': 632521414453538816,
 'id_str': '632521414453538816',
 'in_reply_to_screen_name': None,
 'in_reply_to_status_id': None,
 'in_reply_to_status_id_str': None,
 'in_reply_to_user_id': None,
 'in_reply_to_user_id_str': None,
 'is_quote_status': False,
 'lang': 'en',
 'place': None,
 'retweet_count': 0,
 'retweeted': False,
 'source': '<a href="http://brobeur.com" rel="nofollow">brobeurtweet</a>',
 'text': 'Price of port-royalis 456',
 'truncated': False,
 'user': {'contributors_enabled': False,
  'created_at': 'Sat Mar 30 01:44:05 +0000 2013',
  'default_profile': False,
  'default_profile_image': False,
  'description': 'Video Game Development. #gamedev #linux #getsdrawn',
  'entities': {'description': {'urls': []},
   'url': {'urls': [{'display_url': 'brobeur.com',
      'expanded_url': 'http://brobeur.com',
      'indices': [0, 22],
      'url': 'http://t.co/KRO9XPRA01'}]}},
  'favourites_count': 12,
  'follow_request_sent': False,
  'followers_count': 615,
  'following': False,
  'friends_count': 682,
  'geo_enabled': False,
  'has_extended_profile': False,
  'id': 1315550370,
  'id_str': '1315550370',
  'is_translation_enabled': False,
  'is_translator': False,
  'lang': 'en',
  'listed_count': 34,
  'location': 'Hamilton, New Zealand',
  'name': 'BroBeur.com',
  'notifications': False,
  'profile_background_color': 'C0DEED',
  'profile_background_image_url': 'http://abs.twimg.com/images/themes/theme1/bg.png',
  'profile_background_image_url_https': 'https://abs.twimg.com/images/themes/theme1/bg.png',
  'profile_background_tile': False,
  'profile_banner_url': 'https://pbs.twimg.com/profile_banners/1315550370/1431862528',
  'profile_image_url': 'http://pbs.twimg.com/profile_images/487211737284739072/HBzP949-_normal.png',
  'profile_image_url_https': 'https://pbs.twimg.com/profile_images/487211737284739072/HBzP949-_normal.png',
  'profile_link_color': '300808',
  'profile_sidebar_border_color': 'C0DEED',
  'profile_sidebar_fill_color': 'DDEEF6',
  'profile_text_color': '333333',
  'profile_use_background_image': True,
  'protected': False,
  'screen_name': 'brobeur',
  'statuses_count': 930,
  'time_zone': 'Auckland',
  'url': 'http://t.co/KRO9XPRA01',
  'utc_offset': 43200,
  'verified': False}}

In [ ]:


In [72]:
fpathz = (prodir + pricewhat + '/' + pricewhat + '-price')

In [73]:
wrpric = open(fpathz, 'w')

In [74]:
wrpric.write(priceset)


Out[74]:
3

In [75]:
wrpric.close()

In [76]:
rdpric = open(fpathz, 'r')

print (rdpric.read)

rdpric.close()


<built-in method read of _io.TextIOWrapper object at 0x74ae65b0>

In [77]:
#oprics = open('/home/wcmckee/sellcoffee/products/' + pricewhat + '/index.json', 'r')

In [78]:
os.chdir('/home/wcmckee/sellcoffee/products/')

In [ ]:


In [ ]: