forcing everything python3, might end up with bugs
This commit is contained in:
@@ -19,7 +19,7 @@ function listfiles() {
|
||||
}
|
||||
function count_size() {
|
||||
|
||||
cat - | python -c "import sys
|
||||
cat - | python3 -c "import sys
|
||||
def sizeof_fmt(num, suffix='B'):
|
||||
for unit in ['','K','M','G','T','P','E','Z']:
|
||||
if num < 1024.0:
|
||||
|
||||
@@ -22,7 +22,7 @@ function listfolders() {
|
||||
}
|
||||
function count_size() {
|
||||
|
||||
cat - | python -c "import sys
|
||||
cat - | python3 -c "import sys
|
||||
def sizeof_fmt(num, suffix='B'):
|
||||
for unit in ['','K','M','G','T','P','E','Z']:
|
||||
if num < 1024.0:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import scipy.misc
|
||||
import numpy as n
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: latin-1 -*-
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import zip
|
||||
from builtins import str
|
||||
from past.utils import old_div
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
@@ -8,7 +15,8 @@ import subprocess
|
||||
import hashlib
|
||||
import magic
|
||||
from argparse import ArgumentParser
|
||||
import ConfigParser,StringIO,io
|
||||
import configparser
|
||||
import io
|
||||
import datetime
|
||||
|
||||
SQLFILE='list_of_files.sqlite'
|
||||
@@ -67,7 +75,7 @@ def setup_options():
|
||||
BADDIRS.extend(options.exclude)
|
||||
if options.duplicate:
|
||||
options.add=not options.add
|
||||
options.startpath=unicode(options.startpath, "UTF-8")
|
||||
|
||||
options.sqlpath=os.path.dirname(os.path.realpath(options.sqlfile))
|
||||
return options
|
||||
|
||||
@@ -78,7 +86,7 @@ def add_recurse(options):
|
||||
db=conn.cursor()
|
||||
prev_path_len=0
|
||||
for path,dirs,files in os.walk(options.startpath,followlinks=options.symlinks):
|
||||
sys.stdout.write(("\r%s%s"%(filename_join(path,".",options),(prev_path_len-len(path))*' ')).encode('utf-8'))
|
||||
sys.stdout.write(("\r%s%s"%(filename_join(path,".",options),(prev_path_len-len(path))*' ')))
|
||||
prev_path_len=len(path)
|
||||
dirs=clean_dirs(dirs)
|
||||
dirs.sort()
|
||||
@@ -218,11 +226,11 @@ def createdb(options):
|
||||
object TEXT)')
|
||||
conn.commit()
|
||||
|
||||
config = ConfigParser.RawConfigParser()
|
||||
config = configparser.RawConfigParser()
|
||||
config.add_section("General")
|
||||
config.set("General","Relative",str(options.relative))
|
||||
config.set("General","FullFile",str(options.fullfile))
|
||||
store=StringIO.StringIO()
|
||||
store=io.StringIO()
|
||||
config.write(store)
|
||||
db.execute("INSERT INTO config (object) values (?)",(store.getvalue(),))
|
||||
conn.commit()
|
||||
@@ -337,7 +345,7 @@ def get_md5(filename,fullfile=False):
|
||||
anim_i=0
|
||||
anim_len=len(ANIM)
|
||||
block_size=2**24
|
||||
percents_per_block=100/(float(fsize)/block_size)
|
||||
percents_per_block=old_div(100,(old_div(float(fsize),block_size)))
|
||||
md5 = hashlib.md5()
|
||||
with open(filename,'rb') as f:
|
||||
for chunk in iter(lambda: f.read(block_size), b''):
|
||||
@@ -425,7 +433,7 @@ def humanize_size(size,precision=1):
|
||||
defPrecision=0
|
||||
while size > 1024:
|
||||
suffixIndex += 1 #increment the index of the suffix
|
||||
size = size/1024.0 #apply the division
|
||||
size = old_div(size,1024.0) #apply the division
|
||||
defPrecision=precision
|
||||
return "%.*f%s"%(defPrecision,size,suffixes[suffixIndex])
|
||||
|
||||
@@ -510,7 +518,7 @@ def stored_options(options):
|
||||
store=""
|
||||
for row in db:
|
||||
store+=row[0]+'\n'
|
||||
config = ConfigParser.RawConfigParser()
|
||||
config = configparser.RawConfigParser()
|
||||
config.readfp(io.BytesIO(store))
|
||||
options.relative=config.getboolean("General","Relative")
|
||||
options.fullfile=config.getboolean("General","FullFile")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os, argparse, sys
|
||||
from shutil import copyfile, copytree
|
||||
from datetime import datetime
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import sys,os
|
||||
from Tkinter import *
|
||||
from PIL import Image,ImageTk, ImageDraw
|
||||
import math
|
||||
from argparse import ArgumentParser
|
||||
from argparse import ArgumentParser
|
||||
import sqlite3
|
||||
|
||||
SQLFILE='list_of_images.sqlite'
|
||||
@@ -16,9 +16,9 @@ def setup_options():
|
||||
parser.add_argument("-t",action="store",dest="tags",default="thisIsGood,thisIsBad",
|
||||
help="Comma separated list of tags")
|
||||
parser.add_argument("-n",action="store",type=int,dest="number",default=0,
|
||||
help="Number of tags expected. 0 is any amount.")
|
||||
help="Number of tags expected. 0 is any amount.")
|
||||
parser.add_argument('path', action="store",default='.', nargs='?')
|
||||
|
||||
|
||||
options=parser.parse_args()
|
||||
options.tags=[x.strip() for x in options.tags.split(",")]
|
||||
return options
|
||||
@@ -26,7 +26,7 @@ def setup_options():
|
||||
|
||||
class Click:
|
||||
def __init__(self, image,tags,sqlfile,title,number):
|
||||
|
||||
|
||||
self.title=title
|
||||
self.root=Tk()
|
||||
self.root.geometry("1024x768+220+0")
|
||||
@@ -40,7 +40,7 @@ class Click:
|
||||
self.img_copy= self.image.copy()
|
||||
self.pixels = self.img_copy.load()
|
||||
self.background_image = ImageTk.PhotoImage(self.image)
|
||||
|
||||
|
||||
self.background = Label(self.root, image=self.background_image, cursor='cross')
|
||||
self.background.pack(fill="both", expand=True, side="left")
|
||||
self.background.bind('<Configure>', self._resize_image)
|
||||
@@ -68,14 +68,14 @@ class Click:
|
||||
self.tags[t+1].bind("<Return>", self._tag_key)
|
||||
self.tags.append(Button(self.top, text="Custom", command=self._tag_button("custom")))
|
||||
self.tags[t+2].pack(fill="both", side="top")
|
||||
|
||||
|
||||
self.top.geometry("220x%d+0+0"%(self.root.winfo_screenheight()-150,))
|
||||
|
||||
|
||||
self._resize_init()
|
||||
|
||||
|
||||
self._init_db(sqlfile)
|
||||
self._print_tags()
|
||||
|
||||
|
||||
self.root.mainloop()
|
||||
|
||||
def _tag_key(self,event):
|
||||
@@ -102,12 +102,12 @@ class Click:
|
||||
self.image = self.img_copy.resize((new_width, new_height))
|
||||
self.background_image = ImageTk.PhotoImage(self.image)
|
||||
self.background.configure(image = self.background_image)
|
||||
|
||||
|
||||
def _resize_init(self):
|
||||
event = self._get_max_size()
|
||||
self.root.geometry("%dx%d+220+0"% (event.width, event.height))
|
||||
self._resize_image(event)
|
||||
|
||||
|
||||
def _get_max_size(self,refer_size=None):
|
||||
""" return max size for image that fits the refer_size,.
|
||||
otherwise, return max size for the screen """
|
||||
@@ -122,14 +122,14 @@ class Click:
|
||||
if new_width>refer_width:
|
||||
new_width=refer_width
|
||||
new_height=int(float(self.img_copy.size[1])/float(self.img_copy.size[0])*new_width)
|
||||
event = type('eventclass', (object,),
|
||||
event = type('eventclass', (object,),
|
||||
{'width':new_width, 'height':new_height})()
|
||||
return event
|
||||
|
||||
|
||||
def _quit(self,event):
|
||||
self.root.destroy()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def _next(self,event):
|
||||
self.root.destroy()
|
||||
|
||||
@@ -155,7 +155,7 @@ class Click:
|
||||
if self.numberLimit>0 and self.numberLimit<self.numberCurrent:
|
||||
self._next(0)
|
||||
return
|
||||
|
||||
|
||||
def _print_tags(self):
|
||||
self.db[0].execute("SELECT hash FROM list WHERE file = ?",( os.path.realpath( self.image_name), ))
|
||||
hashes=self.db[0].fetchall()
|
||||
@@ -164,10 +164,10 @@ class Click:
|
||||
self._next(None)
|
||||
return
|
||||
self.db[0].execute("SELECT tag FROM tags WHERE hash = ?",( hashes[0][0], ))
|
||||
|
||||
|
||||
print("tags: "+",".join([x[0] for x in self.db[0]]))
|
||||
return
|
||||
|
||||
|
||||
def _init_db(self, sqlfile):
|
||||
if not os.path.exists(sqlfile):
|
||||
print("Cannot find SQLite file: "+sqlfile)
|
||||
@@ -176,12 +176,12 @@ class Click:
|
||||
conn.text_factory=str
|
||||
db=conn.cursor()
|
||||
self.db=[db,conn]
|
||||
|
||||
|
||||
def get_tags(self):
|
||||
return self.tagTexts
|
||||
|
||||
def _hotkey(self,i):
|
||||
# return string number for 1-9
|
||||
# return string number for 1-9
|
||||
# a-l if i>9
|
||||
if i<10:
|
||||
return str(i)
|
||||
@@ -201,7 +201,7 @@ if os.path.isfile(opt.path):
|
||||
imagelist=[opt.path]
|
||||
else:
|
||||
imagelist=sorted([os.path.join(opt.path,f) for f in os.listdir(opt.path) if IMGMATCH.match(f)])
|
||||
|
||||
|
||||
for i,l in enumerate(imagelist):
|
||||
(p,b)=os.path.split( os.path.abspath(l) )
|
||||
(f,p)=os.path.split( p )
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# coding=UTF-8
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import os,time,datetime
|
||||
import sqlite3
|
||||
import subprocess,shlex
|
||||
from argparse import ArgumentParser
|
||||
from argparse import ArgumentParser
|
||||
|
||||
SQLFILE=os.path.expandvars('$HOME/.rsync-queue.sqlite')
|
||||
|
||||
@@ -55,7 +56,7 @@ def createdb(fname):
|
||||
conn.text_factory=str
|
||||
db.execute('CREATE TABLE list (id INTEGER PRIMARY KEY AUTOINCREMENT,\
|
||||
SRC TEXT,TGT TEXT, exitcode INTEGER)')
|
||||
conn.commit()
|
||||
conn.commit()
|
||||
return
|
||||
|
||||
def mark_done(options, SRC,TGT, exitcode):
|
||||
@@ -105,9 +106,9 @@ def list_URLs(options):
|
||||
db.execute("SELECT * FROM list ORDER BY id")
|
||||
else:
|
||||
db.execute("SELECT * FROM list WHERE exitcode > 0 ORDER BY id")
|
||||
print "EC\tSRC\tTGT"
|
||||
print("EC\tSRC\tTGT")
|
||||
for row in db:
|
||||
print "%s\t%s\t%s" % (row[3],row[1],row[2])
|
||||
print("%s\t%s\t%s" % (row[3],row[1],row[2]))
|
||||
return
|
||||
|
||||
def start_sync(options):
|
||||
@@ -121,7 +122,7 @@ def start_sync(options):
|
||||
command=['rsync']
|
||||
command.extend(syncopts)
|
||||
command.extend([SRC,TGT])
|
||||
popen = subprocess.Popen(command,
|
||||
popen = subprocess.Popen(command,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=8)
|
||||
j=1
|
||||
try:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
|
||||
Reference in New Issue
Block a user