artcgallery

artcontrol gallery

Create gallery for artcontrol artwork.

Uses Year / Month / Day format.

Create blog post for each day there is a post.

It will need to list the files for that day and create a markdown file in posts that contains the artwork. Name of art then followed by each pience of artwork -line, bw, color.

write a message about each piece of artwork.

need to read a config file which lists the blog to update.

In [80]:
import os
import arrow
import getpass
import configparser
import time
import subprocess
#import boto
In [2]:
myusr = getpass.getuser()
In [3]:
raw = arrow.now()
In [4]:
yraw = raw.strftime("%Y")
mntaw = raw.strftime("%m")
dytaw = raw.strftime("%d")
In [5]:
#dytaw = str(28)
In [6]:
fulda = yraw + '/' + mntaw + '/' + dytaw
In [7]:
fultim = fulda + ' ' + raw.strftime('%H:%M:%S')
In [8]:
arnow = arrow.now()
In [9]:
curyr = arnow.strftime('%Y')
In [10]:
curmon = arnow.strftime('%m')
In [11]:
curday = arnow.strftime('%d')
In [12]:
#curday = '28'
In [18]:
#config = configparser.ConfigParser()
In [57]:
config = configparser.RawConfigParser()
In [58]:
artpath = '/home/{}/.config/artcgallery.ini'.format(myusr)
In [59]:
artpath
Out[59]:
'/home/wcm/.config/artcgallery.ini'
In [60]:
#config.add_section('test')
##config.set('test', 'defaultpath', '15')
#config.set('test', 'postname', 'true')
#config.set('test', 'imgorigin', 'true')    
    # Writing our configuration file to 'example.cfg'
#with open(artpath, 'w') as configfile:
#    config.write(configfile)
In [61]:
try:
    config.add_section('test')
    config.set('test', 'defaultpath', '/home/wcm/artctrl/')
    config.set('test', 'postname', 'willtest')
    config.set('test', 'imgorigin', '/home/wcm/aug17/')    
    # Writing our configuration file to 'example.cfg'
    with open(artpath, 'w') as configfile:
        config.write(configfile)
except configparser.DuplicateSectionError:
    print('config exists')
In [62]:
config.read(artpath)
Out[62]:
['/home/wcm/.config/artcgallery.ini']
In [63]:
config = configparser.RawConfigParser()
config.read('/home/{}/.config/artcgallery.ini'.format(myusr))

# getfloat() raises an exception if the value is not a float
# getint() and getboolean() also do this for their respective types
defpath = (config.get('test', 'defaultpath'))
nameofblogpost = (config.get('test', 'postname'))
imgorigin = config.get('test', 'imgorigin')
In [64]:
#artctrlpath = '/home/{}/git/artctrl-stage'.format(myusr)
In [65]:
galerdir = ('{}/galleries/'.format(defpath))
In [66]:
pathdir = ('{}/posts/'.format(defpath))
In [67]:
oslispa = os.listdir(pathdir)
In [68]:
galdir = os.listdir(galerdir)
In [69]:
if curyr in galdir:
    pass
else:
    os.mkdir(galerdir + curyr)
In [70]:
mondir = os.listdir(galerdir + curyr)
In [71]:
if curmon in mondir:
    pass
else:
    os.mkdir(galerdir + curyr + '/' + curmon)
In [72]:
daydir = os.listdir(galerdir + curyr + '/' + curmon )
In [73]:
fridpath = ('{}{}/{}/{}').format(galerdir, curyr, curmon, curday)
In [74]:
fulldaypath = (galerdir + curyr + '/' + curmon + '/' + curday)
In [75]:
if curday in daydir:
    pass
else:
    os.mkdir(galerdir + curyr + '/' + curmon + '/' + curday)
In [76]:
daypost = ('{}/posts/{}.md'.format(defpath, nameofblogpost))
In [ ]:
 
In [77]:
daymetapost = ('{}/posts/{}.meta'.format(defpath, nameofblogpost))
In [78]:
daymdpost = ('{}/posts/{}.md'.format(defpath, nameofblogpost))
In [81]:
subprocess.call('scp -r {}/*.png {}'.format(imgorigin, fridpath), shell=True)
Out[81]:
0
In [82]:
todayart = os.listdir(fulldaypath)
In [83]:
todayart.sort()
In [84]:
gallerpath = ('/galleries/{}/{}/{}/'.format(curyr, curmon, curday))
In [85]:
urlpatz = 'http://artctrl.me'
In [86]:
patchurl = urlpatz + gallerpath
In [87]:
if nameofblogpost not in oslispa:
    tagblog = input('post tags: ')
    
    with open(daymetapost, 'w') as daympo: 
        daympo.write('.. title: {}\n.. slug: {}\n.. date: {}\n.. tags: {}\n.. link:\n.. description:\n.. type: text'.format(nameofblogpost, nameofblogpost, fultim, tagblog))
    
    with open(daymdpost, 'w') as daymark:
        for toar in todayart:
            thoughon = input('thoughts on: {} '.format(toar))
            daymark.write('![{}]({}{})\n\n{}\n\n'.format(toar.replace('.png', ''), gallerpath, toar, thoughon))
            
            #api.update_with_media('{}{}/{}'.format(gifpat, namofgifsea, ranlocgif), status='Started typing script {} {}'.format(blognam, jointag))
     
    
else:
    pass
post tags: gimp, art
thoughts on: aug17-acct101.png 
thoughts on: aug17-armsquid.png 
thoughts on: aug17-centerportal.png 
thoughts on: aug17-claws.png 
thoughts on: aug17-feelstars.png 
thoughts on: aug17-lovefeet.png 
thoughts on: aug17-pigteeth.png 
thoughts on: aug17-tentsliverl.png 
thoughts on: august17-milfscape.png 
thoughts on: august17-monsterchars.png 
thoughts on: august17-portraitboom.png 
thoughts on: august17-teethscape.png 

check to see if that blog post name already excist, if so error and ask for something more unique!

input art piece writers. Shows the art then asks for input, appending the input below the artwork. Give a name for the art that is appended above.

In [88]:
os.chdir(defpath)
In [ ]:
subprocess.call('nikola build', shell=True)
In [139]:
#os.system('aws s3 sync {} s3://artctrl-staging'.format(defpath))
Out[139]:
256
In [ ]:
#subprocess.call('scp {} s3://artctrl-staging'.format(daypost), shell=True)
In [ ]:
#os.system('scp /media/pi/UNTITED/artcontrolme/posts/' + nameofblogpost + '.* wcmckee@artctrl.me:/home/wcmckee/artcontrolme/posts/')
In [ ]:
#os.system('scp /media/pi/UNTITED/artcontrolme/galleries/' + fridpath + ' ' + nameofblogpost + '.* wcmckee@artctrl.me:/home/wcmckee/artcontrolme/posts/')

Comments

Comments powered by Disqus