コード例 #1
0
ファイル: unload.py プロジェクト: incrazyboyy/RPiTC-X
    def do_ls(self, args):
        """List photo card directory contents."""
        args = args.strip().lower()
        files = self.pc.ls(True, args)

        total_size = 0
        formatter = utils.TextFormatter(
                (
                    {'width': 14, 'margin' : 2},
                    {'width': 12, 'margin' : 2, 'alignment' : utils.TextFormatter.RIGHT},
                    {'width': 30, 'margin' : 2},
                )
            )

        print
        print log.bold(formatter.compose(("Name", "Size", "Type")))

        num_files = 0
        for d in self.pc.current_directories():
            if d[0] in ('.', '..'):
                print formatter.compose((d[0], "", "directory"))
            else:
                print formatter.compose((d[0] + "/", "", "directory"))

        for f in self.pc.current_files():
            print formatter.compose((f[0], utils.format_bytes(f[2]), self.pc.classify_file(f[0])))
            num_files += 1
            total_size += f[2]

        print log.bold("% d files, %s" % (num_files, utils.format_bytes(total_size, True)))
コード例 #2
0
ファイル: scrollunload.py プロジェクト: danwallach/VoteBox-v1
    def updateSelectionStatus(self):
        if self.total_number == 0:
            s = self.__tr("No files selected")

        elif self.total_number == 1:
            s = self.__tr("1 file selected, %1").arg(utils.format_bytes(self.total_size, True))

        else:
            s = self.__tr("%1 files selected, %2").arg(self.total_number).arg(utils.format_bytes(self.total_size, True))

        self.selectionStatusText.setText(s)
コード例 #3
0
ファイル: unload.py プロジェクト: incrazyboyy/RPiTC-X
    def do_unload(self, args):
        """Unload all image files from photocard to current local directory.
        Note:
        \tSubdirectories on photo card are not preserved
        Options:
        -x\tDon't remove files after copy
        -p\tPrint unload list but do not copy or remove files"""
        args = args.lower().strip().split()
        dont_remove = False
        if '-x' in args:
            if self.pc.write_protect:
                log.error("Photo card is write protected. -x not allowed.")
                return
            else:
                dont_remove = True


        unload_list = self.pc.get_unload_list()
        print

        if len(unload_list) > 0:
            if '-p' in args:

                max_len = 0
                for u in unload_list:
                    max_len = max(max_len, len(u[0]))

                formatter = utils.TextFormatter(
                        (
                            {'width': max_len+2, 'margin' : 2},
                            {'width': 12, 'margin' : 2, 'alignment' : utils.TextFormatter.RIGHT},
                            {'width': 12, 'margin' : 2},
                        )
                    )

                print
                print log.bold(formatter.compose(("Name", "Size", "Type")))

                total = 0
                for u in unload_list:
                     print formatter.compose(('%s' % u[0], utils.format_bytes(u[1]), '%s/%s' % (u[2], u[3])))
                     total += u[1]


                print log.bold("Found %d files to unload, %s" % (len(unload_list), utils.format_bytes(total, True)))
            else:
                print log.bold("Unloading %d files..." % len(unload_list))
                total, delta, was_cancelled = self.pc.unload(unload_list, self.cp_status_callback, self.rm_status_callback, dont_remove)
                print log.bold("\n%s unloaded in %d sec (%d KB/sec)" % (utils.format_bytes(total), delta, (total/1024)/delta))

        else:
            print "No image, audio, or video files found."
コード例 #4
0
    def updateSelectionStatus(self):
        if self.total_number == 0:
            s = self.__tr("No files selected")

        elif self.total_number == 1:
            s = self.__tr("1 file selected, %1").arg(
                utils.format_bytes(self.total_size, True))

        else:
            s = self.__tr("%1 files selected, %2").arg(self.total_number).arg(
                utils.format_bytes(self.total_size, True))

        self.selectionStatusText.setText(s)
コード例 #5
0
ファイル: unload.py プロジェクト: csteacherd22/hplip
def status_callback(src, trg, size):
    if size == 1:
        print()
        print(log.bold("Copying %s..." % src))
    else:
        print("\nCopied %s to %s (%s)..." %
              (src, trg, utils.format_bytes(size)))
コード例 #6
0
ファイル: unload.py プロジェクト: incrazyboyy/RPiTC-X
    def do_cache(self, args):
        """Display current cache entries, or turn cache on/off.
        Usage:
        \tDisplay: cache
        \tTurn on: cache on
        \tTurn off: cache off
        """
        args = args.strip().lower()

        if args == 'on':
            self.pc.cache_control(True)

        elif args == 'off':
            self.pc.cache_control(False)

        else:
            if self.pc.cache_state():
                cache_info = self.pc.cache_info()

                t = cache_info.keys()
                t.sort()
                print
                for s in t:
                    print "sector %d (%d hits)" % (s, cache_info[s])

                print log.bold("Total cache usage: %s (%s maximum)" % (utils.format_bytes(len(t)*512), utils.format_bytes(photocard.MAX_CACHE * 512)))
                print log.bold("Total cache sectors: %s of %s" % (utils.commafy(len(t)), utils.commafy(photocard.MAX_CACHE)))
            else:
                print "Cache is off."
コード例 #7
0
ファイル: unload.py プロジェクト: super11/hplip
 def cp_status_callback(self, src, trg, size):
     if size == 1:
         print
         print log.bold("Copying %s..." % src)
     else:
         print "\nCopied %s to %s (%s)..." % (src, trg,
                                              utils.format_bytes(size))
コード例 #8
0
ファイル: scrollunload.py プロジェクト: danwallach/VoteBox-v1
    def Properties(self, item):
        if item is not None:
            if not item.exif_info:
                item.exif_info = self.pc.get_exif_path(item.path)

            ImagePropertiesDlg(item.filename, item.dirname,
                                '/'.join([item.mime_type, item.mime_subtype]),
                                utils.format_bytes(item.size, True),
                                item.exif_info, self).exec_loop()
コード例 #9
0
    def Properties(self, item):
        if item is not None:
            if not item.exif_info:
                item.exif_info = self.pc.get_exif_path(item.path)

            ImagePropertiesDlg(item.filename, item.dirname,
                               '/'.join([item.mime_type, item.mime_subtype]),
                               utils.format_bytes(item.size, True),
                               item.exif_info, self).exec_loop()
コード例 #10
0
ファイル: unload.py プロジェクト: csteacherd22/hplip
    def do_ls(self, args):
        """List photo card directory contents."""
        args = args.strip().lower()
        files = self.pc.ls(True, args)

        total_size = 0
        formatter = utils.TextFormatter((
            {
                'width': 14,
                'margin': 2
            },
            {
                'width': 12,
                'margin': 2,
                'alignment': utils.TextFormatter.RIGHT
            },
            {
                'width': 30,
                'margin': 2
            },
        ))

        print()
        print(log.bold(formatter.compose(("Name", "Size", "Type"))))

        num_files = 0
        for d in self.pc.current_directories():
            if d[0] in ('.', '..'):
                print(formatter.compose((d[0], "", "directory")))
            else:
                print(formatter.compose((d[0] + "/", "", "directory")))

        for f in self.pc.current_files():
            print(
                formatter.compose((f[0], utils.format_bytes(f[2]),
                                   self.pc.classify_file(f[0]))))
            num_files += 1
            total_size += f[2]

        print(
            log.bold("% d files, %s" %
                     (num_files, utils.format_bytes(total_size, True))))
コード例 #11
0
ファイル: unload.py プロジェクト: incrazyboyy/RPiTC-X
    def do_df(self, args):
        """Display free space on photo card.
        Options:
        -h\tDisplay in human readable format
        """
        freespace = self.pc.df()

        if args.strip().lower() == '-h':
            fs = utils.format_bytes(freespace)
        else:
            fs = utils.commafy(freespace)

        print "Freespace = %s Bytes" % fs
コード例 #12
0
ファイル: unload.py プロジェクト: csteacherd22/hplip
    def do_df(self, args):
        """Display free space on photo card.
        Options:
        -h\tDisplay in human readable format
        """
        freespace = self.pc.df()

        if args.strip().lower() == '-h':
            fs = utils.format_bytes(freespace)
        else:
            fs = utils.commafy(freespace)

        print("Freespace = %s Bytes" % fs)
コード例 #13
0
ファイル: unload.py プロジェクト: incrazyboyy/RPiTC-X
    def do_cp(self, args, remove_after_copy=False):
        """Copy files from photo card to current local directory.
        Usage:
        \tcp FILENAME(S)|GLOB PATTERN(S)
        Example:
        \tCopy all JPEG and GIF files and a file named thumbs.db from photo card to local directory:
        \tcp *.jpg *.gif thumbs.db
        """
        args = args.strip().lower()

        matched_files = self.pc.match_files(args)

        if len(matched_files) == 0:
            print "ERROR: File(s) not found."
        else:
            total, delta = self.pc.cp_multiple(matched_files, remove_after_copy, self.cp_status_callback, self.rm_status_callback)

            print log.bold("\n%s transfered in %d sec (%d KB/sec)" % (utils.format_bytes(total), delta, (total/1024)/(delta)))
コード例 #14
0
ファイル: unload.py プロジェクト: super11/hplip
    def do_cp(self, args, remove_after_copy=False):
        """Copy files from photo card to current local directory.
        Usage:
        \tcp FILENAME(S)|GLOB PATTERN(S)
        Example:
        \tCopy all JPEG and GIF files and a file named thumbs.db from photo card to local directory:
        \tcp *.jpg *.gif thumbs.db
        """
        args = args.strip().lower()

        matched_files = self.pc.match_files(args)

        if len(matched_files) == 0:
            print "ERROR: File(s) not found."
        else:
            total, delta = self.pc.cp_multiple(matched_files,
                                               remove_after_copy,
                                               self.cp_status_callback,
                                               self.rm_status_callback)

            print log.bold("\n%s transfered in %d sec (%d KB/sec)" %
                           (utils.format_bytes(total), delta,
                            (total / 1024) / (delta)))
コード例 #15
0
ファイル: unload.py プロジェクト: csteacherd22/hplip
    def do_unload(self, args):
        """Unload all image files from photocard to current local directory.
        Note:
        \tSubdirectories on photo card are not preserved
        Options:
        -x\tDon't remove files after copy
        -p\tPrint unload list but do not copy or remove files"""
        args = args.lower().strip().split()
        dont_remove = False
        if '-x' in args:
            if self.pc.write_protect:
                log.error("Photo card is write protected. -x not allowed.")
                return
            else:
                dont_remove = True

        unload_list = self.pc.get_unload_list()
        print()

        if len(unload_list) > 0:
            if '-p' in args:

                max_len = 0
                for u in unload_list:
                    max_len = max(max_len, len(u[0]))

                formatter = utils.TextFormatter((
                    {
                        'width': max_len + 2,
                        'margin': 2
                    },
                    {
                        'width': 12,
                        'margin': 2,
                        'alignment': utils.TextFormatter.RIGHT
                    },
                    {
                        'width': 12,
                        'margin': 2
                    },
                ))

                print()
                print(log.bold(formatter.compose(("Name", "Size", "Type"))))

                total = 0
                for u in unload_list:
                    print(
                        formatter.compose(
                            ('%s' % u[0], utils.format_bytes(u[1]),
                             '%s/%s' % (u[2], u[3]))))
                    total += u[1]

                print(
                    log.bold(
                        "Found %d files to unload, %s" %
                        (len(unload_list), utils.format_bytes(total, True))))
            else:
                print(log.bold("Unloading %d files..." % len(unload_list)))
                total, delta, was_cancelled = self.pc.unload(
                    unload_list, self.cp_status_callback,
                    self.rm_status_callback, dont_remove)
                print(
                    log.bold("\n%s unloaded in %d sec (%d KB/sec)" %
                             (utils.format_bytes(total), delta,
                              (total / 1024) / delta)))

        else:
            print("No image, audio, or video files found.")
コード例 #16
0
ファイル: scan.py プロジェクト: Distrotech/hplip
        res = device.getOptionObj('resolution').limitAndSet(res)
        
        if scan_mode == 'color':
            scan_size = scan_px * 3 # 3 bytes/px
        else:
            scan_size = scan_px # 1 byte/px

        if scan_size > 52428800: # 50MB
            if res > 600:
                log.warn("Using resolutions greater than 600 dpi will cause very large files to be created.")
            else:
                log.warn("The scan current parameters will cause very large files to be created.")

            log.warn("This can cause the scan to take a long time to complete and may cause your system to slow down.")
            log.warn("Approx. number of bytes to read from scanner: %s" % utils.format_bytes(scan_size, True))
       
        device.setOption('compression', scanner_compression)

        if set_contrast:
            valid_contrast = device.getOptionObj('contrast').constraint
            if contrast >= int(valid_contrast[0]) and contrast <= int(valid_contrast[1]):
                contrast = device.getOptionObj('contrast').limitAndSet(contrast)
            else:
                log.warn("Invalid contrast. Contrast range is (%d, %d). Using closest valid contrast of %d " % (int(valid_contrast[0]), int(valid_contrast[1]), contrast))
                if contrast < int(valid_contrast[0]):
                    contrast = int(valid_contrast[0])
                elif contrast > int(valid_contrast[1]):
                    contrast = int(valid_contrast[1])
                
            
コード例 #17
0
ファイル: unload.py プロジェクト: super11/hplip
                            'margin': 2,
                            'alignment': utils.TextFormatter.RIGHT
                        },
                        {
                            'width': 12,
                            'margin': 2
                        },
                    ))

                    print
                    print log.bold(formatter.compose(("Name", "Size", "Type")))

                    total = 0
                    for u in unload_list:
                        print formatter.compose(
                            ('%s' % u[0], utils.format_bytes(u[1]),
                             '%s/%s' % (u[2], u[3])))
                        total += u[1]

                    print log.bold(
                        "Found %d files to unload, %s\n" %
                        (len(unload_list), utils.format_bytes(total, True)))
                    print log.bold("Unloading files...\n")
                    total, delta, was_cancelled = pc.unload(
                        unload_list, status_callback, None, True)
                    print log.bold("\n%s unloaded in %d sec (%d KB/sec)" %
                                   (utils.format_bytes(total), delta,
                                    (total / 1024) / delta))

            finally:
                pc.umount()
コード例 #18
0
ファイル: unload.py プロジェクト: csteacherd22/hplip
                        },
                        {
                            'width': 12,
                            'margin': 2
                        },
                    ))

                    print()
                    print(log.bold(formatter.compose(
                        ("Name", "Size", "Type"))))

                    total = 0
                    for u in unload_list:
                        print(
                            formatter.compose(
                                ('%s' % u[0], utils.format_bytes(u[1]),
                                 '%s/%s' % (u[2], u[3]))))
                        total += u[1]

                    print(
                        log.bold("Found %d files to unload, %s\n" %
                                 (len(unload_list),
                                  utils.format_bytes(total, True))))
                    print(log.bold("Unloading files...\n"))
                    total, delta, was_cancelled = pc.unload(
                        unload_list, status_callback, None, True)
                    print(
                        log.bold("\n%s unloaded in %d sec (%d KB/sec)" %
                                 (utils.format_bytes(total), delta,
                                  (total / 1024) / delta)))
コード例 #19
0
        if scan_size > 52428800:  # 50MB
            if res > 600:
                log.warn(
                    "Using resolutions greater than 600 dpi will cause very large files to be created."
                )
            else:
                log.warn(
                    "The scan current parameters will cause very large files to be created."
                )

            log.warn(
                "This can cause the scan to take a long time to complete and may cause your system to slow down."
            )
            log.warn("Approx. number of bytes to read from scanner: %s" %
                     utils.format_bytes(scan_size, True))

        device.setOption('compression', scanner_compression)

        if brx - tlx <= 0.0 or bry - tly <= 0.0:
            log.error("Invalid scan area (width or height is negative).")
            sys.exit(1)

        log.info("")
        log.info("Resolution: %ddpi" % res)
        log.info("Mode: %s" % scan_mode)
        log.info("Compression: %s" % scanner_compression)
        log.info("Scan area (mm):")
        log.info("  Top left (x,y): (%fmm, %fmm)" % (tlx, tly))
        log.info("  Bottom right (x,y): (%fmm, %fmm)" % (brx, bry))
        log.info("  Width: %fmm" % (brx - tlx))
コード例 #20
0
ファイル: scan.py プロジェクト: pbrudnick/sitio-facttic
        res = device.getOptionObj('resolution').limitAndSet(res)
        
        if scan_mode == 'color':
            scan_size = scan_px * 3 # 3 bytes/px
        else:
            scan_size = scan_px # 1 byte/px

        if scan_size > 52428800: # 50MB
            if res > 600:
                log.warn("Using resolutions greater than 600 dpi will cause very large files to be created.")
            else:
                log.warn("The scan current parameters will cause very large files to be created.")

            log.warn("This can cause the scan to take a long time to complete and may cause your system to slow down.")
            log.warn("Approx. number of bytes to read from scanner: %s" % utils.format_bytes(scan_size, True))
       
        device.setOption('compression', scanner_compression)

        if brx - tlx <= 0.0 or bry - tly <= 0.0:
            log.error("Invalid scan area (width or height is negative).")
            sys.exit(1)

        log.info("")
        log.info("Resolution: %ddpi" % res)
        log.info("Mode: %s" % scan_mode)
        log.info("Compression: %s" % scanner_compression)
        log.info("Scan area (mm):")
        log.info("  Top left (x,y): (%fmm, %fmm)" % (tlx, tly))
        log.info("  Bottom right (x,y): (%fmm, %fmm)" % (brx, bry))
        log.info("  Width: %fmm" % (brx - tlx))
コード例 #21
0
ファイル: unload.py プロジェクト: incrazyboyy/RPiTC-X
def status_callback(src, trg, size):
    if size == 1:
        print
        print log.bold("Copying %s..." % src)
    else:
        print "\nCopied %s to %s (%s)..." % (src, trg, utils.format_bytes(size))
コード例 #22
0
ファイル: unload.py プロジェクト: incrazyboyy/RPiTC-X
                        max_len = max(max_len, len(u[0]))

                    formatter = utils.TextFormatter(
                            (
                                {'width': max_len+2, 'margin' : 2},
                                {'width': 12, 'margin' : 2, 'alignment' : utils.TextFormatter.RIGHT},
                                {'width': 12, 'margin' : 2},
                            )
                        )

                    print
                    print log.bold(formatter.compose(("Name", "Size", "Type")))

                    total = 0
                    for u in unload_list:
                         print formatter.compose(('%s' % u[0], utils.format_bytes(u[1]), '%s/%s' % (u[2], u[3])))
                         total += u[1]


                    print log.bold("Found %d files to unload, %s\n" % (len(unload_list), utils.format_bytes(total, True)))
                    print log.bold("Unloading files...\n")
                    total, delta, was_cancelled = pc.unload(unload_list, status_callback, None, True)
                    print log.bold("\n%s unloaded in %d sec (%d KB/sec)" % (utils.format_bytes(total), delta, (total/1024)/delta))


            finally:
                pc.umount()

    except KeyboardInterrupt:
        log.error("User exit")
コード例 #23
0
ファイル: setup.py プロジェクト: dhirajpatra/lti_tool
def plugin_download_callback(c, s, t):
    pm.update(int(100*c*s/t),
             utils.format_bytes(c*s))
コード例 #24
0
ファイル: unload.py プロジェクト: danwallach/VoteBox-v1
 def cp_status_callback(self, src, trg, size):
     if size == 1:
         print()
         print(log.bold("Copying %s..." % src))
     else:
         print("\nCopied %s to %s (%s)..." % (src, trg, utils.format_bytes(size)))