def test_organize_func_mosaic_value_exception(self):
     """テスト:写真整理処理例外(カスケード設置値異常)"""
     expected = "Fail to recognize the face!"
     try:
         # テストディレクトリ初期化
         self.setting.test_directory_initialization()
         # テスト用入力ファイルの設置
         shutil.copytree(
             self.TEST_FILE_DIR,
             os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
         # 値が不正なの設定ファイルを設置
         self.setting.config_organize_file_set(
             os.path.join(self.setting.TEST_CONFIG_FILES_DIR,
                          self.setting.TEST_ORGANIZE_CONFIG_DIR,
                          "config_ng_val.ini"))
         # 設定のクリア
         photo.Cleaning._CONFIG = {}
         photo.Cleaning._CASCADE = {}
         # オブジェクトの生成
         target = Photos()
         # テストターゲットの実行
         target.organize()
     except exception.Photo_cascade_exception as ex:
         actual = repr(ex)
         self.assertEqual(expected, actual)
 def test_base_flow_backup_trash_dir_none(self):
     """テスト:設定ファイル・バックアップ&破棄ディレクトリ指定なし"""
     expected = set(self.TEST_OUTPUT_FILES)
     # テストディレクトリ初期化
     self.setting.test_directory_initialization()
     # テスト用入力ファイルの設置
     shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
     # テスト用の設定ファイルを設置
     self.setting.config_file_set(os.path.join(
         self.setting.TEST_CONFIG_FILES_DIR, "config_backup_trash_none.ini"))
     # オブジェクトの生成
     target = Photos()
     # テストターゲットの実行
     target.organize()
     # ターゲットのディクトリが空であること
     result_backup = False
     if not os.path.isdir("./photo/backup"):
         result_backup = True
     result_trash = False
     if not os.path.isdir("./photo/trash"):
         result_trash = True
     # 作成された写真の確認
     actual = set(os.listdir(self.TEST_OUTPUT_DIR))
     # 部分集合で結果を確認
     compare = expected.issuperset(actual)
     self.assertTrue(compare and result_backup and result_trash)
 def test_organize_func_exception(self):
     """テスト:写真整理処理例外(設定値なし)"""
     expected = "Failed to read the configuration file!"
     try:
         # テストディレクトリ初期化
         self.setting.test_directory_initialization()
         # テスト用入力ファイルの設置
         shutil.copytree(
             self.TEST_FILE_DIR,
             os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
         # 空の設定ファイルを設置
         self.setting.config_organize_file_set(
             os.path.join(self.setting.TEST_CONFIG_FILES_DIR,
                          self.setting.TEST_ORGANIZE_CONFIG_DIR,
                          "config_ng_none.ini"))
         # 設定のクリア
         photo.Cleaning._CONFIG = {}
         photo.Cleaning._CASCADE = {}
         # オブジェクトの生成
         target = Photos()
         # テストターゲットの実行
         target.organize()
     except exception.Photo_setting_exception as ex:
         actual = repr(ex)
         self.assertEqual(expected, actual)
 def test_delete_unneeded_func_exception(self):
     """テスト:指定ファイル削除処理例外"""
     expected = "Photo organizing exception!"
     try:
         # オブジェクトの生成
         target = Photos()
         target._delete_unneeded_func("./test/test_delete_unneeded_func_exception.json")
     except exception.Photo_exception as ex:
         actual = repr(ex)
         self.assertEqual(expected, actual)
 def test_base_flow(self):
     """テスト:基本フローのテスト"""
     expected = set(self.TEST_OUTPUT_FILES)
     # テストディレクトリ初期化
     self.setting.test_directory_initialization()
     # テスト用入力ファイルの設置
     shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
     # オブジェクトの生成
     target = Photos()
     # テストターゲットの実行
     target.organize()
     # 作成された写真の確認
     actual = set(os.listdir(self.TEST_OUTPUT_DIR))
     # 部分集合で結果を確認
     compare = expected.issuperset(actual)
     self.assertTrue(compare)
Beispiel #6
0
 def __init__(self, access_token=''):
     self.Account = Account(access_token=access_token)
     self.Apps = Apps(access_token=access_token)
     self.Audio = Audio(access_token=access_token)
     self.Auth = Auth(access_token=access_token)
     self.Board = Board(access_token=access_token)
     self.Database = Database(access_token=access_token)
     self.Docs = Docs(access_token=access_token)
     self.Other = Other(access_token=access_token)
     self.Fave = Fave(access_token=access_token)
     self.Friends = Friends(access_token=access_token)
     self.Gifts = Gifts(access_token=access_token)
     self.Groups = Groups(access_token=access_token)
     self.Likes = Likes(access_token=access_token)
     self.Market = Market(access_token=access_token)
     self.Messages = Messages(access_token=access_token)
     self.Newsfeed = Newsfeed(access_token=access_token)
     self.Notes = Notes(access_token=access_token)
     self.Notifications = Notifications(access_token=access_token)
     self.Pages = Pages(access_token=access_token)
     self.Photos = Photos(access_token=access_token)
     self.Places = Places(access_token=access_token)
     self.Polls = Polls(access_token=access_token)
     self.Search = Search(access_token=access_token)
     self.Stats = Stats(access_token=access_token)
     self.Status = Status(access_token=access_token)
     self.Storage = Storage(access_token=access_token)
     self.Users = Users(access_token=access_token)
     self.Utils = Utils(access_token=access_token)
     self.Video = Video(access_token=access_token)
     self.Wall = Wall(access_token=access_token)
     self.Widgets = Widgets(access_token=access_token)
Beispiel #7
0
def run_tests(key, secret):
	try:
		x = Auth(key, secret)
		x.authenticate()
	except urllib2.HTTPError as e:
		print e.read()
		raise

	filename = "/Users/riyer/Desktop/Screen Shot 2013-06-28 at 7.36.02 PM.png"

	f = open(filename, "rb")
	pic = f.read()

	u = Uploader("test_pic", pic, x)
	u.addTitle("test pic")
	u.setPublic()

	req = u.getRequest()
	try:
		handle = urllib2.urlopen(req)
		res = handle.read()
	except urllib2.HTTPError as e:
		print e.read()
		raise

	photo_id = u.getPhotoIdFromResponse(res)

	p = Photosets(x)
	r = p.createGetListRequest()
	res = execute(r, "createGetListRequest")

	names = p.getPhotosetList(res)

	r = p.createNewSetRequest("test set", "test desc", '9404583236')
	res = execute(r, "createNewSetRequest")

	set_id = p.getPhotosetIdFromResult(res)

	r = p.createAddPhotoRequest(photo_id, set_id)
	execute(r, "createAddPhotoRequest")

	r = p.createPhotosetDeleteRequest(set_id)
	execute(r, "createPhotosetDeleteRequest")

	photos = Photos(x)
	r = photos.createDeletePhotoRequest(photo_id)
	execute(r, "createDeletePhotoRequest")
Beispiel #8
0
def run_tests(key, secret):
    try:
        x = Auth(key, secret)
        x.authenticate()
    except urllib2.HTTPError as e:
        print e.read()
        raise

    filename = "/Users/riyer/Desktop/Screen Shot 2013-06-28 at 7.36.02 PM.png"

    f = open(filename, "rb")
    pic = f.read()

    u = Uploader("test_pic", pic, x)
    u.addTitle("test pic")
    u.setPublic()

    req = u.getRequest()
    try:
        handle = urllib2.urlopen(req)
        res = handle.read()
    except urllib2.HTTPError as e:
        print e.read()
        raise

    photo_id = u.getPhotoIdFromResponse(res)

    p = Photosets(x)
    r = p.createGetListRequest()
    res = execute(r, "createGetListRequest")

    names = p.getPhotosetList(res)

    r = p.createNewSetRequest("test set", "test desc", '9404583236')
    res = execute(r, "createNewSetRequest")

    set_id = p.getPhotosetIdFromResult(res)

    r = p.createAddPhotoRequest(photo_id, set_id)
    execute(r, "createAddPhotoRequest")

    r = p.createPhotosetDeleteRequest(set_id)
    execute(r, "createPhotosetDeleteRequest")

    photos = Photos(x)
    r = photos.createDeletePhotoRequest(photo_id)
    execute(r, "createDeletePhotoRequest")
 def test_thumbnail_exception(self):
     """テスト:サムネイル処理例外"""
     expected = "It failed to create a thumbnail image!"
     try:
         # テストディレクトリ初期化
         self.setting.test_directory_initialization()
         # テスト用入力ファイルの設置
         shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
         # 空の設定ファイルを設置
         self.setting.config_file_set(os.path.join(
             self.setting.TEST_CONFIG_FILES_DIR, "config_ng_thumbnail_exception.ini"))
         # オブジェクトの生成
         target = Photos()
         # テストターゲットの実行
         target.organize()
     except exception.Photo_thumbnail_exception as ex:
         actual = repr(ex)
         self.assertEqual(expected, actual)
 def test_input_dir_none(self):
     """テスト:設定ファイル・入力ディレクトリ指定なし"""
     # テストディレクトリ初期化
     self.setting.test_directory_initialization()
     # テスト用入力ファイルの設置
     shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
     # テスト用の設定ファイルを設置
     self.setting.config_file_set(os.path.join(
         self.setting.TEST_CONFIG_FILES_DIR, "config_ng_input_none.ini"))
     # 設定のクリア
     photo.Cleaning._CONFIG = {}
     # オブジェクトの生成
     target = Photos()
     # テストターゲットの実行
     target.organize()
     # 出力先が空であることを確認
     result = False
     if not os.path.isdir(self.TEST_OUTPUT_DIR):
         result = True
     self.assertTrue(result)
 def test_output_dir_none(self):
     """テスト:設定ファイル・出力ディレクトリ指定なし"""
     expected = "Photo organizing exception!"
     try:
         # テストディレクトリ初期化
         self.setting.test_directory_initialization()
         # テスト用入力ファイルの設置
         shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
         # テスト用の設定ファイルを設置
         self.setting.config_file_set(os.path.join(
             self.setting.TEST_CONFIG_FILES_DIR, "config_ng_output_none.ini"))
         # 設定のクリア
         photo.Cleaning._CONFIG = {}
         # オブジェクトの生成
         target = Photos()
         # テストターゲットの実行
         target.organize()
     except exception.Photo_exception as ex:
         actual = repr(ex)
         self.assertEqual(expected, actual)
 def test_config_none(self):
     """テスト:設定ファイルなし"""
     expected = "Failed to read the configuration file!"
     try:
         # テストディレクトリ初期化
         self.setting.test_directory_initialization()
         # テスト用入力ファイルの設置
         shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
         # からの設定ファイルを設置
         self.setting.config_file_set(os.path.join(
             self.setting.TEST_CONFIG_FILES_DIR, "config_ng_none.ini"))
         photo.Cleaning.config()
         # オブジェクトの生成
         Photos()
     except exception.Photo_setting_exception as ex:
         actual = repr(ex)
         self.assertEqual(expected, actual)
Beispiel #13
0
 def __init__(self, master=None, title=None, video=None):
     ''' Initialice window app '''
     super().__init__(master)        
     self.master = master
     # self.master.geometry('422x624+629+231') -> desarrollo ahead.
     self.pack(fill=tk.BOTH, expand=1)
     self.master.title(title)
     self.master['bg'] = 'Black'
     self.master.protocol('WM_DELETE_WINDOW', self.confirmExit)
     self.master.protocol('WM_TAKE_FOCUS', self.confirmOpen)
     self.master.protocol('WM_SAVE_YOURSELF', self.confirmSave)
     self.init = True
     self.setingfile = 'flash_seting.ini'
     # self.window.resizable(width=False, height=False)
     self.n_size = None
     self.photo = None
     self.photos = Photos()
     # self.master.call('wm', 'iconphoto', self.master, self.photos._apply)
     self.soundvar = tk.DoubleVar(value=0.9)
     self.master.wm_iconphoto(True, self.photos._apply)
     self.dirImages = None
     self.dirpathmovies = tk.StringVar()  # directorio path video
     self.video_source = video
     w = 350; h = 230; self.duracion = 100.0
     self.active_scale = False
     self.vid = None
     self.val = 'paused'
     if self.video_source is not None:
         # open video source (by default this will try to open the computer webcam)
         try:
             self.dirpathmovies.set(os.path.dirname(self.video_source))
             self.vid = VideoStream(self.video_source)
             # w_f, h_f = self.vid.w, self.vid.h
             self.duracion = self.vid.duration
             self.soundvar.set(self.vid.player.get_volume())
             frame = None
             while frame is None:
                 self.val, self.pts, frame = self.vid.get_frame()
             size = frame.get_size()
             arr = frame.to_memoryview()[0] # array image
             self.imagen = Image.frombytes("RGB", size, arr.memview)
             w_f, h_f = self.imagen.size
             self.delay = self.vid.f_rate
             self.vid.toggle_pause()
             self._wxh = (w_f, (h_f + 40))
             self._twh = (300, 300)
         except Exception as e:
             print(e)
             self.video_source = None
     else:
         self.imagen = self.photos._logo
         w_f, h_f = self.imagen.size
         self.delay = 16
         self._wxh = (422, 624)
         self._twh = (629, 231)
         pass
     # ajuste ventana.
     str_window = str(self._wxh[0])+ 'x'+str(self._wxh[1])+ '+' + str(self._twh[0])+ '+' + str(self._twh[1])
     self.master.geometry(str_window)
     print('str ventana de inicio:', str_window)
     # event changed de volume
     self.soundvar.trace('w', self.soundvar_adjust)
     # Create a canvas that can fit the above video source size
     self.canvas = tk.Canvas(self, bg='red')
     # contenedor de controles
     self.conten_controls = tk.LabelFrame(self, height=4)
     # Button that lets the user take a snapshot
     self.btn_snapshot=tk.Button(self.conten_controls, text="Snapshot", command=self.snapshot)
     self.btn_snapshot['image'] = self.photos._snapshot 
     self.btn_snapshot.pack(side='left')
     # Button open
     self.btn_open = tk.Button(self.conten_controls, text='...', command=self.open_file)
     self.btn_open['image'] = self.photos._open
     self.btn_open.pack(side='right')
     # button volum
     self.btn_volume = tk.Button(self.conten_controls, text='volume', command=self.open_adjust_volumen)
     self.btn_volume['image'] = self.photos._volume
     self.btn_volume.pack(side='right')
     # Button replay
     self.btn_replay = tk.Button(self.conten_controls, text=">>", command=self.replay)
     self.btn_replay['image'] = self.photos._repeat
     self.btn_replay.pack(side='right')
     # Button play-pausa
     self.btn_toogle_pause = tk.Button(self.conten_controls, text="[]", command=self.toogle_pause)
     self.btn_toogle_pause['image'] = self.photos._play
     self.btn_toogle_pause.pack(side='right')
     # Slade
     self.var_t = tk.DoubleVar()
     self.scale = tk.Scale(self.conten_controls, from_=0.0, to= self.duracion, showvalue=0, orient='horizontal', variable=self.var_t, 
                     resolution=0.3, sliderrelief='flat', command=self.onScale )
     self.scale.pack(side='left', fill='x', expand=1)
     self.scale.bind('<ButtonPress-1>', self.scale_button_press)
     self.scale.bind('<ButtonRelease-1>', self.scale_button_release)
     self.master.bind('<Configure>', self.master_on_resize)
     # self.master.bind_all('<ButtonPress-1>', self.master_button_press)
     # self.master.bind('<ButtonRelease-1>', self.master_button_release)
     # self.master.wm_withdraw()
     self.canvas.pack(side =tk.TOP, fill=tk.BOTH, expand=1)
     self.conten_controls.pack(side='bottom', fill='x')
     
     
     if self.video_source is not None:
         self.scale.configure(to=self.duracion)
         self.btn_toogle_pause['image'] = self.photos._pause
         self.vid.player.set_volume(float(self.soundvar.get()))
         self.canvas_tags = None
         
     self.photo = ImageTk.PhotoImage(self.imagen)
     self.canvas.configure(width = w_f, height=h_f)
     self.canvas.create_image(w_f/2, h_f/2, image = self.photo, 
                                     anchor='center', tags='img')
     self.val = None
     self.pts = None
     #
     
   
     if self.video_source is None:
         self.get_init_status()
     self.update()
     self.master.mainloop()
Beispiel #14
0
		print (" albums:")
		if len(al.albums) != 0:
			print albums
		else: print "empty"
	elif selection == '4':
		print (" photo bmp:")
		photos.search(ph,'bmp')
	elif selection == '5':
		return 0
	else:
		menu()
		return
	menu()

dbfile = "dbfile.dat"
photos = Photos()
albums = Albums()

with open(dbfile,"rb") as file:
	photos = pickle.load(file)
	albums = pickle.load(file)
	
#album1 = Album(0, 'A', '11/9/2017')
#album2 = Album(1, 'B', '10/9/2017')
#album3 = Album(2, 'C', '21/9/2017')
#albums.add(album1)
#albums.add(album2)
#albums.add(album3)
al = albums

#photo1 = Photo(0, 'aaa', 'jpg', 'B')
Beispiel #15
0
class SubTreeNode(tree.TreeNode):
    """ 
    继承父类tree.TreeNode,增加Ctrl+左键及右键的功能, 可多选,当右键时打开jpg文件
    """
    path_list = []
    img_type = 'jpg'    
    photos = Photos()
    def __init__(self, dir_canvas, parent, item):
        tree.TreeNode.__init__(self, dir_canvas, parent, item)

        

    def get_path_list(self, suffix=img_type):
        """ get img_type file list such as get jpg files"""
        img_list = list(filter(lambda x: x.endswith(suffix), self.path_list))
        return img_list

    def select_or_edit(self, event=None):
        self.path_list.clear()
        if self.selected and self.item.IsEditable():
            self.edit(event)
        else:
            self.path_list.append(self.item.path)
            self.select(event)

    def select_more(self, event=None):
        """Control + 左键 触发选择多个文件或目录"""
        self.path_list.append(self.item.path)
        # if self.selected:
        #     return
        # self.deselectall()
        self.selected = True
        # self.canvas.delete(self.image_id)
        self.drawicon()
        self.drawtext()

    def execute_file(self, event=None):
        """ open jpg file or merge several jpg file then open it"""
        file_list = self.get_path_list()
        print(file_list)
        if not file_list:
            return
        # merge image
        # 修复内存泄露的bug,由于没有清除之前打开的图片,第二次打开的图片仍然为之前的图片
        try:
            self.photos.destroy()
        except:
            pass
        self.photos.imgs = file_list  
        merged_photo = self.photos.merge_photos()

        # show image
        try:
            window.destroy()
        except:
            import traceback
            traceback.print_exc()
        window.build_img_canvas()
        window.show_img_in_canvas(merged_photo)
        
        
    def drawtext(self):
        textx = self.x+20-1
        texty = self.y-4
        labeltext = self.item.GetLabelText()
        if labeltext:
            id = self.canvas.create_text(textx, texty, anchor="nw",
                                         text=labeltext)
            self.canvas.tag_bind(id, "<1>", self.select)
            self.canvas.tag_bind(id, "<Double-1>", self.flip)
            x0, y0, x1, y1 = self.canvas.bbox(id)
            textx = max(x1, 200) + 10
        text = self.item.GetText() or "<no text>"
        try:
            self.entry
        except AttributeError:
            pass
        else:
            self.edit_finish()
        try:
            self.label
        except AttributeError:
            # padding carefully selected (on Windows) to match Entry widget:
            self.label = Label(self.canvas, text=text, bd=0, padx=2, pady=2)
        theme = idleConf.CurrentTheme()
        if self.selected:
            self.label.configure(idleConf.GetHighlight(theme, 'hilite'))
        else:
            self.label.configure(idleConf.GetHighlight(theme, 'normal'))
        id = self.canvas.create_window(textx, texty,
                                       anchor="nw", window=self.label)
        self.label.bind("<1>", self.select_or_edit)
        self.label.bind("<Double-1>", self.flip)
        self.label.bind("<Control-1>", self.select_more)
        self.label.bind("<3>", self.execute_file)
        self.text_id = id
Beispiel #16
0
import time

from flask import render_template
from flask import Response

from team import app
from members import Members
from whereabouts import Whereabouts
from photos import Photos

team = Members().load(app.config['TEAM_TSV_URL'])

whereabouts = Whereabouts(app.config['WHEREABOUTS_TSV_URL'])

photos = Photos(app.config['PHOTO_URL'],
                username=app.config.get('PHOTO_USERNAME', ''),
                password=app.config.get('PHOTO_PASSWORD', ''))


@app.route('/')
def _home():
    return render_template('index.html')


@app.route('/cards')
def _cards():
    return render_template('cards.html', members=team.members)


@app.route('/whereabouts')
def _whereabouts_today():