In [141]:
import requests
import shutil
import os
import getpass
from urllib.parse import urlparse
import json
import arrow
import glob
import os
import arrow
import time
import subprocess

In [115]:
def mkyr(blogpath):
    raw = arrow.now()
    if raw.strftime("%Y") not in os.listdir(blogpath + '/galleries'):
        os.mkdir(blogpath + '/galleries/' + raw.strftime("%Y"))
        #return(raw.strftime("%Y"))
    else:
        return('ERROR: Year already exists')

In [116]:
def mkmth(blogpath):
    raw = arrow.now()
    if raw.strftime("%m") not in os.listdir(blogpath + '/galleries/' + raw.strftime("%Y")):
        os.mkdir(blogpath + '/galleries/' + raw.strftime("%Y") + '/' + raw.strftime("%m"))
        return(raw.strftime("%m"))
    else:
        return('ERROR: Month already exists')

In [117]:
def mkday(blogpath):
    raw = arrow.now()
    if raw.strftime("%d") not in os.listdir(blogpath + '/galleries/' + raw.strftime("%Y") + '/' + raw.strftime("%m")):
        os.mkdir(blogpath + '/galleries/' + raw.strftime("%Y") + '/' + raw.strftime("%m") + '/' + raw.strftime('%d'))
        return(raw.strftime('%d'))
    else:
        return('ERROR: Day already exists')

In [139]:
def cpdayimg(orginpath, blogpath):
    #copies images from origin folder to blog folder
    raw = arrow.now()
    files = os.listdir(orginpath)
    for f in files:
        shutil.copy(orginpath + '/' + f, blogpath + '/galleries/' + raw.strftime("%Y") + '/' + raw.strftime("%m") + '/' + raw.strftime('%d'))
    return(os.listdir(blogpath + '/galleries/' + raw.strftime("%Y") + '/' + raw.strftime("%m") + '/' + raw.strftime('%d')))

In [140]:
cpdayimg('/home/wcmckee/imgtest', '/home/wcmckee/artctrl-test/')


Out[140]:
['1017-05_BTS_WEB_HOME_wk14_2.jpg',
 '1017-05_BTS_WEB_HOME_wk14_28.jpg',
 '1017-05_BTS_WEB_HOME_wk14_32.jpg',
 '1017-05_BTS_WEB_HOME_wk14_30.jpg',
 '1017-05_BTS_WEB_HOME_wk14_26.jpg',
 'test.jpg',
 '1017-05_BTS_WEB_HOME_wk14_24.jpg',
 'david.jpg',
 '1017-05_BTS_WEB_HOME_wk14_16.jpg',
 '1017-05_BTS_WEB_HOME_wk14_10.jpg',
 '1017-05_BTS_WEB_HOME_wk14_4.jpg']

In [129]:
def mkblogpost(blogpath, postname, tagblog):
    raw = arrow.now()
    fultim = raw.datetime
    
    if postname + '.md' not in os.listdir(blogpath + '/posts'):
        with open(blogpath + '/posts/' + postname + '.meta', 'w') as daympo:
            daympo.write('.. title: {}\n.. slug: {}\n.. date: {}\n.. tags: {}\n.. link:\n.. description:\n.. type: text'.format(postname, postname, fultim, tagblog))
            
        with open(blogpath + '/posts/' + postname + '.md', 'w') as daymark:
            for toar in os.listdir(blogpath + '/galleries/' + raw.strftime("%Y") + '/' + raw.strftime("%m") + '/' + raw.strftime('%d')):

                daymark.write('![{}]({}{})\n\n'.format(toar.replace('.png', ''), '/galleries/' + raw.strftime("%Y") + '/' + raw.strftime("%m") + '/' + raw.strftime('%d') + '/', toar))

    else:
        return('ERROR: post already exists')

In [178]:
import awscli

In [179]:
awscli.en


Out[179]:
<module 'awscli' from '/usr/lib/python3/dist-packages/awscli/__init__.py'>

In [181]:
awscli.EnvironmentVariables


Out[181]:
{'ca_bundle': ('ca_bundle', 'AWS_CA_BUNDLE', None, None),
 'output': ('output', 'AWS_DEFAULT_OUTPUT', 'json', None)}

In [ ]:


In [136]:
def syncblogpost():
    #rsync the galleries and post files to various services - aws and digitalocean bucket.


  File "<ipython-input-136-95d777530b3b>", line 2
    #rsync the galleries and post files to various services - aws and digitalocean bucket.
                                                                                           ^
SyntaxError: unexpected EOF while parsing

folder of images. create request that creates json of image name, id, and text descrion. this is the text that goes after the image.


In [163]:
def imgjstru(blogpath, postname):
    sampdict = dict()
    raw = arrow.now()
    for osli in os.listdir(blogpath + '/galleries/' + raw.strftime("%Y") + '/' + raw.strftime("%m") + '/' + raw.strftime('%d')):
        #print(osli)
        sampdict.update({osli : dict({'id' : 'one', 'text' : 'sampletext'})})
    #os.listdir(blogpath + '/galleries/' + raw.strftime("%Y") + '/' + raw.strftime("%m") + '/' + raw.strftime('%d'))
    return(sampdict)

In [173]:
def singimg(blogpath, postname, imgname, imgtxt):
    sampdict = dict()
    raw = arrow.now()
  
    with open(blogpath + '/posts/' + postname + '.md', 'a') as daymark:
        daymark.write('![{}]({}{})\n\n{}\n\n'.format(imgname.replace('.png', ''), '/galleries/' + raw.strftime("%Y") + '/' + raw.strftime("%m") + '/' + raw.strftime('%d') + '/', imgname, imgtxt))

In [174]:
singimg('/home/wcmckee/artctrl-test', 'omgz', 'hello.png', 'this is lame')

In [175]:
singimg('/home/wcmckee/artctrl-test', 'omgz', 'never.png', 'well this didnt look good')

In [ ]:


In [ ]:


In [164]:
sam


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-164-3ef32f8c6790> in <module>()
----> 1 sam

NameError: name 'sam' is not defined

In [165]:
imgjstru('/home/wcmckee/artctrl-test', 'testing')


Out[165]:
{'1017-05_BTS_WEB_HOME_wk14_10.jpg': {'id': 'one', 'text': 'sampletext'},
 '1017-05_BTS_WEB_HOME_wk14_16.jpg': {'id': 'one', 'text': 'sampletext'},
 '1017-05_BTS_WEB_HOME_wk14_2.jpg': {'id': 'one', 'text': 'sampletext'},
 '1017-05_BTS_WEB_HOME_wk14_24.jpg': {'id': 'one', 'text': 'sampletext'},
 '1017-05_BTS_WEB_HOME_wk14_26.jpg': {'id': 'one', 'text': 'sampletext'},
 '1017-05_BTS_WEB_HOME_wk14_28.jpg': {'id': 'one', 'text': 'sampletext'},
 '1017-05_BTS_WEB_HOME_wk14_30.jpg': {'id': 'one', 'text': 'sampletext'},
 '1017-05_BTS_WEB_HOME_wk14_32.jpg': {'id': 'one', 'text': 'sampletext'},
 '1017-05_BTS_WEB_HOME_wk14_4.jpg': {'id': 'one', 'text': 'sampletext'},
 'david.jpg': {'id': 'one', 'text': 'sampletext'},
 'test.jpg': {'id': 'one', 'text': 'sampletext'}}

In [ ]:


In [ ]:


In [ ]: