a=[1, 3, 5]for i in a: print(a)
mogrify -format jpg ~/project/*.png ; #mogrify -resize 300x300 ~/project/*.jpg ; #rm -f ~/project/*.jpg~* ;
SENDER=`formail -zxFrom:|cut -f2- -d'<' | cut -f1 -d'>'`# Из писем с темой Render извлечь вложение и положить его в files домашнего каталога получателя:0 * ^From.** ^Subject:.*Render* !^FileName.*.zip { :0 c : # Anything from hgfh |/bin/mkdir -p $ATTACHDIR/$SENDER # will go to $MAILDIR/unrar :0 c : #Скрипт извлечение архива |ripmime -i - --no-nameless -d $ATTACHDIR -p header -e :0 aw |. ~/d/filtermail2.sh # /bin/mkdir ~/ < (formail-X From) ; then mkdir -m 0750 «$NDIR» fi formail -X 'From: adr' > mkdir ~/d/$adr}
#!-*- coding: utf-8 -*-import osdef filtermail2() : def unzip() : unzip_zip = os.popen('/usr/bin/unzip ~/d/*.zip') rm_zip = unzip() def rm() : rm_zip = os.popen('/bin/rm -f ~/d/*.zip') zip_blend = rm() def find() : find_blend = os.popen('/bin/find ~/d/ -maxdepth 1 -type f -name "*.blend" -printf "%f\n" >> ~/project/file_list.txt') find_blend = find() def mv() : mv_zipblend = os.popen('/bin/mv -f ~/d/*.blend ~/project') mv_blend = mv() filtermail2_script = filtermail2()
#!/bin/bashcd ~/project/ ; ./blender -b --python new_time_render.py
#!-*- coding: utf-8 -*-import bpy, osimport datetimeimport time #импортировали модуль для работы со временемdef seach_file() : try : def write() : write_file_list = os.popen('/bin/find ~/render_file -maxdepth 1 -type f -name "*.blend" -printf "%f\n" >> ~/project/file_list.txt') time.sleep(2) write_blend = write() def cp() : cp = os.popen('/bin/cp ~/render_file/*.blend ~/project/') cp_blend = cp() time.sleep(2) def rm() : rm = os.popen('~/render_file/*.blend') del_blend = rm() time.sleep(5) #file_list = open('~/project/file_list.txt','a') #file_list.writelines('\n'+ name_file)# #print name_file #file_list.close() except : passdef send_mail() : mail_list = open('~/project/mail_list.txt','r') st = mail_list.readlines() for i in range(len(st)) : # Открываем файл только для чтения f = open('~/project/send_mail.sh', 'r') lines = f.readlines() lines = ('#!/bin/bash'+'\n mutt -s "Rendering" адрес@mail.ru < ~/project/render_go.txt ;') print ("запись названия файла в txt для письма" ) rendlist = render_go() # Открываем файл для записи save_changes = open('~/project/send_mail.sh', 'w') # Сохраняем список строк save_changes.writelines(lines) mail_list.close() f.close() save_changes.close() p = os.popen(". ~/project/send_mail.sh") def t_converter() : #!-*- coding: utf-8 -*- p = os.popen(". ~/project/converter_jpg.sh")def t_send_jpg() : mail_list = open('~/project/mail_list.txt','r') st = mail_list.readlines() for i in range(len(st)) : f = open('~/project/send_jpg.sh', 'r') lines = f.readlines() lines = ('#!/bin/bash'+'\n mutt -s "Rendering" адрес@mail.ru -a ~/project/*.jpg < ~/project/text.txt ;').format(st[-1]) save_changes = open('send_jpg.sh', 'w') save_changes.writelines(lines) mail_list.close() f.close() save_changes.close() p = os.popen(". ~/project/send_jpg.sh")def render_go(): file_list = open('~/project/file_list.txt','r') st = file_list.readlines() for i in range(len(st)) : # Открываем файл только для чтения f = open('~/project/render_go.txt', 'r') lines = f.readlines() lines = ('-------------------'+'\n Начало рендеринга '+'\n-------------------'+'\n|{} ' ).format(a[-1]) # Открываем файл для записи save_changes = open('~/project/render_go.txt', 'w') # Сохраняем список строк save_changes.writelines(lines) file_list.close() f.close()list = os.listdir()a = []def render() : list = os.listdir() name_file = a[-1] name_file = name_file.strip() print (name_file , "файл из списка") for x in list : if name_file == str(x): print ("из списка записать название крайнего файла") rendgo = render_go() # Открываем файл только для чтения #f = open('/home/serg/project/render_go.txt', 'r') #lines = f.readlines() #lines = ('-------------------'+'\n Начало рендеринга '+'\n-------------------'+'\n|{} ' ).format(name_file) # Открываем файл для записи #save_changes = open('~/project/render_go.txt', 'w') # Сохраняем список строк #save_changes.writelines(lines) #file_list.close() #f.close() print ("отправка письма с началом рендеринга") time.sleep(2) sendm = send_mail() print("открытие blend файла программой из дирректории") time.sleep(2) bpy.ops.wm.open_mainfile(filepath = name_file ) print ("загрузка сцен из blend фалйла в дирректории") scn = bpy.data.scenes for i in scn: time.sleep(2) namef = str(name_file+'_'+str(i.name) ) i.render.filepath = ('\\/~/project\\'+namef ) try : try : print ( "начало рендеринга") bpy.ops.render.render(write_still = True , scene = i.name) print ( "сохранение картинки 1") except : pass print ("начало рендеринга") bpy.ops.render.CYCLES(write_still = True , scene = i.name) print ( "сохранение картинки 1") break mail_list = open('~/project/mail_list.txt','r') st = mail_list.readlines() st = st[-1] print ("чтение имейла из майл листа") time.sleep(2) def mk_dir(): print ("создание папки сименем имейла") p = os.popen(("/bin/mkdir ~/d/{}").format(st)) mk = mk_dir() time.sleep(2) def cp_image(): print ("файл изображения ="+namef) print ( "копирование картинки из папки project в папку d ") p = os.popen(("/bin/cp '~/project/'{}.* /home/serg/d/{}").format(namef,st)) print ("копирование картинки из папки project в папку render_file ") p = os.popen(("/bin/cp '~/project/'{}.* /home/serg/render_file").format(namef)) mk = cp_image() time.sleep(2) print (" конвертирование картинки в jpg формат") mail = t_converter() time.sleep(2) print ( "отправка письма с jpg картинкой") mail_jpg = t_send_jpg() time.sleep(2) print ( " удаление картинки png в папке project") os.remove('~/project/'+name_file+'_'+str(i.name)+'.png') time.sleep(2) print ("удаление картинки jpg в папке project" ) os.remove('~/project/'+name_file+'_'+str(i.name)+'.jpg') except : pass os.remove(name_file) finally: pass os.remove(name_file)while True : try: '''while True : try: seach_blend = seach_file() except KeyboardInterrupt: print ('Отменено чтение файла') finally: time.sleep(10) print ("отсутствие файла_в_папке_render_file") break''' f = open('~/project/file_list.txt') line = '' def z() : b = [] k = [] for line0 in open('~/project/file_list.txt') : #читать строку,открыли на чтение line0 = line0.strip() '''print (line0, "строка из файл листа")''' if len(line0) != 0 : b.append(line0) k.append(line0) if (len(k)-1) > (len(a)-1) : s = b.pop() a.append(s) time.sleep(2) try : rend = render() time.sleep(5) except : pass g = z() f.close() time.sleep(10) print ("отсутствие файла в файловом листе") except KeyboardInterrupt: print ('Отменено чтение файла') finally: f.close() time.sleep(10) print ("отсутствие файла в файловом листе2") if __name__ == '__main__': main()