# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import logging from collections import OrderedDict from gettext import gettext as _ from os.path import basename, isabs, isfile, join, splitext from re import match from time import time import venco.config as config from venco.utils.files import deleteFile, getSize, mkDir, ls as fileLs, SizedFile from venco.utils.messages import ProgressAction config.setDefaults('main', {'debug': ''}) logger = logging.getLogger('kuaipanMain') url = '.' ds = [] fs = OrderedDict() UPLOAD_LIMIT = 300 << 20 CHUNK_SIZE = 1 << 21 # 2MB at a time class Collect: ''' Calculates total size for progress bar, and collects paths. :param path: str, current path :param ls: function, lists directory contents for source (local files if upload, remote ones if download) :param ds: list of str, selected directories :param fs: OrderedDict {name: SizedFile}, selected files
from venco.utils.messages import getText, ProgressAction, showConfirm currentDir = dirname(realpath(__file__)) logging.basicConfig(filename=join(currentDir, 'run.log'), level=logging.INFO, format='%(asctime)s,%(funcName)s,%(lineno)d: %(message)s', datefmt='%d %H:%M:%S') logger = logging.getLogger('main') logging.getLogger('requests').setLevel(logging.WARNING) for i in ('mate', 'gnome', 'cinnamon'): try: # TODO nicer method to get system theme name? QtGui.QIcon.setThemeName(check_output(split('gsettings get org.{}.interface icon-theme'.format(i))).strip()[1:-1].decode('utf-8')) break except: pass # confirm setting defaults config.setDefaults('confirm', {'upload': True, 'download': True, 'movedownload': True, 'moveupload': True, 'del': True, 'quit': False}) config.setDefaults('shortcut', # shortcut setting defaults {'AddTab': 'Ctrl+T', 'LastTab': 'Ctrl+Shift+T', 'Quit': 'Alt+X', 'Delete': 'Delete', 'Copy': 'F5', 'Move': 'F6', 'NewDir': 'F7', 'Shortcuts': 'Ctrl+H', 'Preferences': 'Ctrl+P', 'Confirms': 'Ctrl+O', 'Back': 'Alt+Left', 'Next': 'Alt+Right', 'Up': 'BackSpace', 'Home': 'Home', 'Close': 'Ctrl+W', 'Reload': 'Ctrl+R', 'ChangeNextTab': 'Ctrl+Tab', 'ChangePrevTab': 'Ctrl+Shift+Tab'}) # actions available with their translated name actions = {'AddTab': _('New tab'), 'LastTab': _('Reopen last tab'), 'Quit': _('Quit'), 'Copy': _('Copy'), 'Move': _('Move'), 'NewDir': _('New folder'), 'Delete': _('Delete'), 'Shortcuts': _('Shortcuts'), 'Preferences': _('Preferences'), 'Confirms': _('Confirms'), 'Back': _('Back'), 'Next': _('Forward'), 'Up': _('Up'), 'Close': _('Close'), 'Home': _('Home'), 'Reload': _('Reload'), 'ChangeNextTab': _('Next tab'), 'ChangePrevTab': _('Previous tab')} menuStructure = (('File', _('File'), ('AddTab', 'LastTab', 'Quit')), # menu structure as (menu name, translated label, tuple of actions) ('Action', _('Action'), ('Copy', 'Move', 'NewDir', 'Delete')), ('Settings', _('Settings'), ('Shortcuts', 'Preferences', 'Confirms'))) toolStructure = ('Copy', 'Move', 'NewDir', 'Delete', 'Quit') # toolbar actions