示例#1
0
    def upgrade_status(self):
        """docstring for upgrade_status"""
        axapi_module = 'upgrade-status/oper'
        method = 'GET'

        latest_status = 0
        upgrading = True
        while upgrading:
            r = self.axapi_call(axapi_module, method)
            if r.status_code == 200:
                current_status = r.json()['upgrade-status']['oper']['status']
                if current_status != latest_status:
                    latest_status = current_status
                    message = r.json()['upgrade-status']['oper']['message']
                    if current_status == 10:
                        upgrading = False
                    elif current_status > 7:
                        display.error(message, self.hostname)
                        upgrading = False
                        continue
                    display.info(message, self.hostname)
            else:
                print(r)
                upgrading = False
            time.sleep(3)
示例#2
0
 def logoff(self):
     """docstring for logoff"""
     display.info("Logging off...", self.hostname)
     axapi_module = 'logoff'
     method = 'POST'
     r = self.axapi_call(axapi_module, method)
     display.info(self.axapi_status(r), self.hostname)
示例#3
0
 def write_memory(self):
     """docstring for write_memory"""
     display.info("Saving configuration...", self.hostname)
     axapi_module = 'write/memory'
     method = 'POST'
     r = self.axapi_call(axapi_module, method)
     display.info(self.axapi_status(r), self.hostname)
示例#4
0
 def show_version(self):
     """docstring for show_version"""
     axapi_module = 'version/oper'
     r = self.axapi_call(axapi_module)
     self.versions = r.json()['version']['oper']
     display.info("Current running ACOS is {}."
                  .format(self.versions['sw-version']), self.hostname)
示例#5
0
 def reboot(self):
     """docstring for reboot"""
     display.info("Rebooting. The appliance could be unavailable for up to 5\
           minutes...", self.hostname)
     axapi_module = 'reboot'
     method = 'POST'
     r = self.axapi_call(axapi_module, method)
     display.info(self.axapi_status(r), self.hostname)
示例#6
0
 def update_bootimage(self, upgrade_location, short_upgrade_location):
     display.info("Updating bootimage to {}..."
                  .format(upgrade_location), self.hostname)
     axapi_module = 'bootimage'
     method = 'POST'
     payload = {
         "bootimage": {"hd-cfg": {"hd": 1, short_upgrade_location: 1}}}
     r = self.axapi_call(axapi_module, method, payload)
     display.info(self.axapi_status(r), self.hostname)
示例#7
0
 def get_bootimage(self):
     """docstring for bootimage"""
     try:
         boot_location = self.versions['boot-from']
         if boot_location == 'HD_PRIMARY':
             self.current_image = 'primary'
         elif boot_location == 'HD_SECONDARY':
             self.current_image = 'secondary'
     except Exception as e:
         display.error(e, self.hostname)
         return 'FAIL'
     display.info("Booted from the {} image location,"
                  .format(self.current_image), self.hostname)
     return self.current_image
示例#8
0
    def __init__(self):

        display.info(str(sys.argv[0:]) + '\n')

        try:
            opts, extraparams = getopt.getopt(sys.argv[1:],"p:t:i:h",
                                              ["pictures=",
                                               "temporal_levels=",
                                               "pictures_per_second=",
                                               "help"
                                               ])
        except getopt.GetoptError, exc:
            sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
            sys.exit(2)
示例#9
0
 def authenticate(self, user, passwd):
     """docstring for authenticate"""
     display.info('Logging on...', self.device)
     axapi_module = 'auth'
     method = 'POST'
     payload = {"credentials": {"username": user, "password": passwd}}
     try:
         r = self.axapi_call(axapi_module, method, payload)
     except Exception as e:
         display.error('Unable to connect - {}'
                       .format(e),
                       self.hostname)
         return 'FAIL'
     try:
         token = r.json()['authresponse']['signature']
         self.headers['Authorization'] = 'A10 {}'.format(token)
     except Exception as e:
         display.error(e, self.hostname)
         return 'FAIL'
示例#10
0
 def show_bootimage(self):
     """docstring for show_bootimage"""
     axapi_module = 'bootimage/oper'
     r = self.axapi_call(axapi_module)
     bootimage = r.json()['bootimage']['oper']
     star = '(*)'
     pri_star = ''
     sec_star = ''
     if bootimage['hd-default'] == 'hd-pri':
         pri_star = star
     elif bootimage['hd-default'] == 'hd-sec':
         sec_star = star
     display.info('show bootimage', self.hostname)
     display.write('                       (* = Default)')
     display.write('                           Version')
     display.write(' -----------------------------------------------')
     display.write(' Hard Disk primary         {} {}'
                   .format(bootimage['hd-pri'], pri_star))
     display.write(' Hard Disk secondary       {} {}'
                   .format(bootimage['hd-sec'], sec_star))
     display.write('')
示例#11
0
    def upgrade_image(self, upgrade, upgrade_bootimage=False):
        """docstring for upgrade_image"""
        if upgrade_bootimage:
            upgrade_location = self.current_image
        else:
            if self.current_image == 'primary':
                upgrade_location = 'secondary'
            elif self.current_image == 'secondary':
                upgrade_location = 'primary'
            else:
                display.fatal('Something went wrong',
                              self.hostname)
                return 'FAIL'

        short_upgrade_location = upgrade_location[:3]
        display.info("Upgrading {} image via {}"
                     .format(upgrade_location, upgrade['protocol']),
                     self.hostname)
        display.info('The upgrade process may take some time...',
                     self.hostname)
        axapi_module = 'upgrade/hd'
        method = 'POST'
        payload = {"hd": {"image": short_upgrade_location,
                          "use-mgmt-port": int(self.use_mgmt),
                          "file-url": upgrade['uri']}}
        r = self.axapi_call(axapi_module, method, payload)
        status = self.axapi_status(r)

        if r.status_code == 202:  # This means we have more data to gather
            self.upgrade_status()
        elif status == 'fail':
            display.error(status, self.hostname)
            return 'FAIL'
        else:
            display.info(status, self.hostname)

        if self.set_bootimage:
            self.update_bootimage(upgrade_location, short_upgrade_location)
    sys.stderr.write("+-------------------------------+\n")
    sys.stderr.write("\n")
    sys.stderr.write("  Description:\n")
    sys.stderr.write("   Expand the LFB texture data using Motion JPEG.\n")
    sys.stderr.write("\n")
    sys.stderr.write("  Parameters:\n")
    sys.stderr.write("\n")
    sys.stderr.write("   -[-f]ile = file that contains the LFB data (\"%s\")\n" % file)
    sys.stderr.write("   -[-l]layers = number of quality layers to decode (%d)\n" % layers)
    sys.stderr.write("   -[-p]ictures = number of images to process (%d)\n" % pictures)
    sys.stderr.write("   -[-t]emporal_levels = number of temporal levels (%d)\n" % temporal_levels)
    sys.stderr.write("\n")

opts = ""

display.info(str(sys.argv[0:]) + '\n')

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],
                                      "f:l:p:t:h",
                                      ["file=",
                                       "layers=",
                                       "pictures=",
                                       "temporal_levels=",
                                       "help"
                                       ])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)

for o, a in opts:
import display

## Name of the file with the motion fields.
file = ""

## Documentation of usage.
#  -[-f]ile = Name of the file with the motion fields.
def usage():
    sys.stderr.write("+-----------------------+\n")
    sys.stderr.write("| MCTF motion_expand_cp |\n")
    sys.stderr.write("+-----------------------+\n")

## Define the variable for options.
opts = ""

try:
    opts, extraparams = getopt.getopt(sys.argv[1:], "f:h", ["file=", "help"])

except getopt.GetoptError, exc:
    display.info(sys.argv[0] + ": " + exc.msg + "\n")

for o, a in opts:
    if o in ("f", "--file"):
        file = a
        display.info(sys.argv[0] + ": file=" + file + '\n')
    if o in ("h", "--help"):
        usage()
        sys.exit()

os.system("cp " + file + ".cp " + file)
blocks_in_y = 0
fields = 0
file = ""

def usage():
    sys.stderr.write("+--------------------------+\n")
    sys.stderr.write("| MCTF motion_compress_j2k |\n")
    sys.stderr.write("+--------------------------+\n")
    sys.stderr.write("   -[-]blocks_in_[x]=number of blocks in the X direction (%d)\n" % blocks_in_x)
    sys.stderr.write("   -[-]blocks_in_[y]=number of blocks in the Y direction (%d)\n" % blocks_in_y)
    sys.stderr.write("   -[-i]iteration=temporal iteration (%d)\n" % iterationi)
    sys.stderr.write("   -[-f]ields=number of fields in input (%d)\n" % fields)
    sys.stderr.write("   -f[-i]le=name of the file with the motion fields (\"%s\")\n" % file)

ifdef({{DEBUG}},
display.info(str(sys.argv[0:]) + '\n')
)

opts = ""

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],
                                      "x:y:t:f:i:h",
                                      ["blocks_in_x=",
                                       "blocks_in_y=",
                                       "iteration=",
                                       "fields=",
                                       "file=",
                                       "help"
                                       ])
示例#15
0
#  - -[-]pixels_in_[x]=size of the X dimension of the pictures.
#  - -[-]pixels_in_[Y]=size of the Y dimension of the pictures.
def usage():
    sys.stderr.write("\n")
    sys.stderr.write("  Description:\n")
    sys.stderr.write("\n")
    sys.stderr.write("    Compute the Kbps/GOP.\n")
    sys.stderr.write("\n")
    sys.stderr.write("  Parameters:\n")
    sys.stderr.write("\n")
    sys.stderr.write("   -[-]pixels_in_[x]=size of the X dimension of the pictures (%d)\n" %  pixels_in_y)
    sys.stderr.write("   -[-]pixels_in_[y]=size of the Y dimension of the pictures (%d)\n" %  pixels_in_x)
    sys.stderr.write("\n")

ifdef({{DEBUG}},
display.info(str(sys.argv[0:]) + '\n')
)

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],"o:x:y::h",
                                      ["original=",
                                       "pixels_in_x=",
                                       "pixels_in_y=",
                                       "help"
                                       ])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)

for o, a in opts:
    if o in ("-o", "--original"):
示例#16
0
    sys.stderr.write("  Description:\n")
    sys.stderr.write("\n")
    sys.stderr.write("    Compute the Kbps/GOP.\n")
    sys.stderr.write("\n")
    sys.stderr.write("  Parameters:\n")
    sys.stderr.write("\n")
    sys.stderr.write(
        "   -[-]pixels_in_[x]=size of the X dimension of the pictures (%d)\n" %
        pixels_in_y)
    sys.stderr.write(
        "   -[-]pixels_in_[y]=size of the Y dimension of the pictures (%d)\n" %
        pixels_in_x)
    sys.stderr.write("\n")


ifdef({{DEBUG}}, display.info(str(sys.argv[0:]) + '\n'))

try:
    opts, extraparams = getopt.getopt(
        sys.argv[1:], "o:x:y::h",
        ["original=", "pixels_in_x=", "pixels_in_y=", "help"])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)

for o, a in opts:
    if o in ("-o", "--original"):
        ## Original signal.
        original = a
        ifdef({{DEBUG}},
              display.info(sys.argv[0] + ": original=" + original + '\n'))
pictures = 33
temporal_levels = 5

def usage():
    sys.stderr.write("+---------------------------+\n")
    sys.stderr.write("| MCTF motion_compress_gzip |\n")
    sys.stderr.write("+---------------------------+\n")
    sys.stderr.write("   -[-]blocks_in_[x]=number of blocks in the X direction (%d)\n" % blocks_in_x)
    sys.stderr.write("   -[-]blocks_in_[y]=number of blocks in the Y direction (%d)\n" % blocks_in_y)
    sys.stderr.write("   -[-i]iteration=temporal iteration (%d)\n" % iterationi)
    sys.stderr.write("   -[-f]ile=name of the file with the motion fields (\"%s\")\n" % file)
    sys.stderr.write("   -[-p]ictures=number of images to process (%d)\n" % pictures)
    sys.stderr.write("   -[-t]emporal_levels=number of temporal levels (%d)\n" % temporal_levels)

ifdef({{DEBUG}},
display.info(str(sys.argv[0:]) + '\n')
)

opts = ""

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],
                                      "x:y:i:f:p:t:h",
                                      ["blocks_in_x=",
                                       "blocks_in_y=",
                                       "iteration=",
                                       "file=",
                                       "pictures=",
                                       "temporal_levels=",
                                       "help"
                                       ])
示例#18
0
    sys.stderr.write("\n")
    sys.stderr.write("   Expand the texture data.\n")
    sys.stderr.write("\n")
    sys.stderr.write("  Parameters:\n")
    sys.stderr.write("\n")
    sys.stderr.write("   -[-l]layers=number of quality layers to decode (%d)\n" % layers)
    sys.stderr.write("   -[-p]ictures=number of images to process (%d)\n" % pictures)
    sys.stderr.write("   -[-]pixels_in_[x]=size of the X dimension of the pictures (%d)\n" %  pixels_in_y)
    sys.stderr.write("   -[-]pixels_in_[y]=size of the Y dimension of the pictures (%d)\n" %  pixels_in_x)
    sys.stderr.write("   -[-t]emporal_levels=number of iterations of the temporal transform + 1 (%d)\n" % temporal_levels)
    sys.stderr.write("\n")

opts = ""

ifdef({{DEBUG}},
display.info(str(sys.argv[0:]) + '\n')
)

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],"l:p:x:y:t:h",
                                      ["layers=",
                                       "pictures=",
                                       "pixels_in_x=",
                                       "pixels_in_y=",
                                       "temporal_levels=",
                                       "help"])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)

for o, a in opts:
示例#19
0
    sys.stderr.write("\n")
    sys.stderr.write("   Extracts a number of quality layers.\n")
    sys.stderr.write("\n")
    sys.stderr.write("  Parameters:\n")
    sys.stderr.write("\n")
    sys.stderr.write("   -[-l]ayers=number of extracted quality layers (\"%d\")\n" % layers)
    sys.stderr.write("   -[-p]ictures=number of images to process (%d)\n" % pictures)
    sys.stderr.write("   -[-]pixels_in_[x]=size of the X dimension of the pictures (%d)\n" %  pixels_in_x)
    sys.stderr.write("   -[-]pixels_in_[y]=size of the Y dimension of the pictures (%d)\n" %  pixels_in_y)
    sys.stderr.write("   -[-t]emporal_levels=number of iterations of the temporal transform + 1 (%d)\n" % temporal_levels)
    sys.stderr.write("\n")

opts = ""

ifdef({{DEBUG}},
display.info(str(sys.argv[0:]) + '\n')
)

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],"l:p:x:y:t:h",
                                      ["layers=",
                                       "pictures=",
                                       "pixels_in_x=",
                                       "pixels_in_y=",
                                       "temporal_levels=",
                                       "help"
                                       ])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)
    
示例#20
0
    sys.stderr.write("\n")
    sys.stderr.write("  Parameters:\n")
    sys.stderr.write("\n")
    sys.stderr.write("   -[-]block_o[v]erlaping = number of overlaped pixels between the blocks in the motion estimation (%d)\n" % block_overlaping)
    sys.stderr.write("   -[-b]lock_size = size of the blocks in the motion estimation process (%d)\n" % block_size)
    sys.stderr.write("   -[-]block_si[z]e_min = minimal block size allowed in the motion estimation (%d)\n" % block_size_min)
    sys.stderr.write("   -[-p]ictures = number of images to process (%d)\n" % pictures)
    sys.stderr.write("   -[-]pixels_in_[x] = size of the X dimension of the pictures (%d)\n" %  pixels_in_y)
    sys.stderr.write("   -[-]pixels_in_[y] = size of the Y dimension of the pictures (%d)\n" %  pixels_in_x)
    sys.stderr.write("   -[-s]earch_range = size of the searching area of the motion estimation (%d)\n" % search_range)
    sys.stderr.write("   -[-]subpixel_[a]ccuracy = sub-pixel accuracy of the motion estimation (%d)\n" % subpixel_accuracy)
    sys.stderr.write("   -[-t]emporal_levels = number of iterations of the temporal transform + 1 (%d)\n" % temporal_levels)
    sys.stderr.write("\n")

ifdef({{DEBUG}},
display.info(str(sys.argv[0:]) + '\n')
)

opts = ""

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],
                                      "v:b:z:p:x:y:s:a:t:h",
                                      ["block_overlaping=",
                                       "block_size=",
                                       "block_size_min=",
                                       "pictures=",
                                       "pixels_in_x=",
                                       "pixels_in_y=",
                                       "search_range=",
                                       "subpixel_accuracy=",
示例#21
0
 def get_hostname(self):
     """docstring for get_hostname"""
     axapi_module = 'hostname'
     r = self.axapi_call(axapi_module)
     self.hostname = r.json()['hostname']['value']
     display.info("Logged on successfully", self.hostname)
示例#22
0
    sys.stderr.write(
        "   -[-f]ile = file that contains the LFB data (\"%s\")\n" % file)
    sys.stderr.write(
        "   -[-l]layers = number of quality layers to decode (%d)\n" % layers)
    sys.stderr.write("   -[-p]ictures = number of textures to process (%d)\n" %
                     textures)
    sys.stderr.write(
        "   -[-t]emporal_levels = number of temporal levels (%d)\n" %
        temporal_levels)
    sys.stderr.write("\n")


## Define the variable for options.
opts = ""

display.info(str(sys.argv[0:]) + '\n')

try:
    opts, extraparams = getopt.getopt(
        sys.argv[1:], "f:l:p:t:h",
        ["file=", "layers=", "textures=", "temporal_levels=", "help"])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)

for o, a in opts:
    if o in ("-f", "--file"):
        file = a
        display.info(sys.argv[0] + ": file=" + file + '\n')

    if o in ("-l", "--layers"):
示例#23
0
    sys.stderr.write("\n")
    sys.stderr.write("  Parameters:\n")
    sys.stderr.write("\n")
    sys.stderr.write("   -[-f]ile = file that contains the HFB data (\"%s\")\n" % file)
    sys.stderr.write("   -[-p]ictures = number of images to process (%d)\n" % pictures)
    sys.stderr.write("   -[-]pixels_in_[x] = size of the X dimension of the pictures (%d)\n" % pixels_in_x)
    sys.stderr.write("   -[-]pixels_in_[y] = size of the Y dimension of the pictures (%d)\n" % pixels_in_y)
    sys.stderr.write("   -[-s]lopes = distortion-length slope value for the only quality layer (%s)\n" % "", slopes)
    sys.stderr.write("   -[-]sub[b]and = subband to compress (%d)\n" % subband)
    sys.stderr.write("   -[-t]emporal_levels = number of temporal levels (%d)\n" % temporal_levels)
    sys.stderr.write("\n")

## Define the variable for options.
opts = ""

display.info(str(sys.argv[0:]) + '\n')

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],"f:p:s:x:y:b:t:h",
                                      ["file=",
                                       "pictures=",
                                       "pixels_in_x=",
                                       "pixels_in_y=",
                                       "subband=",
                                       "slopes=",
                                       "temporal_levels=",
                                       "help"
                                       ])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)
    sys.stderr.write(
        "   -[-]pixels_in_[x]=size of the X dimension of the pictures (%d)\n" %
        pixels_in_x)
    sys.stderr.write(
        "   -[-]pixels_in_[y]=size of the Y dimension of the pictures (%d)\n" %
        pixels_in_y)
    sys.stderr.write(
        "   -[-t]emporal_levels=number of iterations of the temporal transform + 1 (%d)\n"
        % temporal_levels)
    sys.stderr.write("\n")


## Define the variable for options.
opts = ""

ifdef({{DEBUG}}, display.info(str(sys.argv[0:]) + '\n'))

try:
    opts, extraparams = getopt.getopt(sys.argv[1:], "l:p:x:y:t:h", [
        "layers=", "pictures=", "pixels_in_x=", "pixels_in_y=",
        "temporal_levels=", "help"
    ])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)

## Define the variable for params.
params = ""

for o, a in opts:
    if o in ("-l", "--layers"):
示例#25
0
    sys.stderr.write(
        "   -[-]s[l]opes=distortion-length slope for each quality layer (\"%s\")\n"
        % slopes)
    sys.stderr.write(
        "   -[-]subpixel_[a]ccuracy=sub-pixel accuracy of the motion estimation (%d)\n"
        % subpixel_accuracy)
    sys.stderr.write(
        "   -[-t]emporal_levels=number of iterations of the temporal transform + 1 (%d)\n"
        % temporal_levels)
    sys.stderr.write("\n")


## Define the variable for options.
opts = ""

ifdef({{DEBUG}}, display.info(str(sys.argv[0:]) + '\n'))

try:
    opts, extraparams = getopt.getopt(
        sys.argv[1:], "v:b:z:d:p:x:y:l:p:a:t:h", [
            "block_overlaping=", "block_size=", "block_size_min=",
            "border_size=", "original=", "pictures=", "pixels_in_x=",
            "pixels_in_y=", "search_range=", "slopes=", "subpixel_accuracy=",
            "temporal_levels=", "help"
        ])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)

for o, a in opts:
    if o in ("-v", "--block_overlaping"):
示例#26
0
    sys.stderr.write(
        "   -[-f]ile = file that contains the HFB data (\"%s\")\n" % file)
    sys.stderr.write(
        "   -[-l]layers = number of quality layers to decode (%d)\n" % layers)
    sys.stderr.write("   -[-p]ictures = number of images to process (%d)\n" %
                     pictures)
    sys.stderr.write(
        "   -[-t]emporal_levels = number of temporal levels (%d)\n" %
        temporal_levels)
    sys.stderr.write("\n")


## Define the variable for options.
opts = ""

ifdef({{DEBUG}}, display.info(str(sys.argv[0:]) + '\n'))

try:
    opts, extraparams = getopt.getopt(
        sys.argv[1:], "f:l:p:t:h",
        ["file=", "layers=", "pictures=", "temporal_levels=", "help"])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)

for o, a in opts:
    if o in ("-f", "--file"):
        file = a
        display.info(sys.argv[0] + ": file=" + file + '\n')

    if o in ("-l", "--layers"):
示例#27
0
    sys.stderr.write("\n")
    sys.stderr.write("  Parameters:\n")
    sys.stderr.write("\n")
    sys.stderr.write("   -[-]block_o[v]erlaping = number of overlaped pixels between the blocks in the motion estimation (%d)\n" % block_overlaping)
    sys.stderr.write("   -[-b]lock_size = size of the blocks in the motion estimation process (%d)\n" % block_size)
    sys.stderr.write("   -[-]bor[d]der_size = size of the border of the blocks in the motion estimation process (%d)\n" % border_size)
    sys.stderr.write("   -[-p]ictures = number of images to process (%d)\n" % pictures)
    sys.stderr.write("   -[-]pixels_in_[x] = size of the X dimension of the pictures (%d)\n" %  pixels_in_y)
    sys.stderr.write("   -[-]pixels_in_[y] = size of the Y dimension of the pictures (%d)\n" %  pixels_in_x)
    sys.stderr.write("   -[-s]earch_range = size of the searching area of the motion estimation (%d)\n" % search_range)
    sys.stderr.write("   -[-]subpixel_[a]ccuracy = sub-pixel accuracy of the motion estimation (%d)\n" % subpixel_accuracy)
    sys.stderr.write("   -[-t]emporal_subband = iteration of the temporal transform (%d)\n" % temporal_subband)
    sys.stderr.write("\n");

ifdef({{DEBUG}},
display.info(str(sys.argv[0:]))
)

opts = ""

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],"v:b:d:p:x:y:s:a:t:h",
                                      ["block_overlaping=",
                                       "block_size=",
                                       "border_size=",
                                       "pictures=",
                                       "pixels_in_x=",
                                       "pixels_in_y=",
                                       "search_range=",
                                       "subpixel_accuracy=",
                                       "temporal_subband=",
    sys.stderr.write(
        "   -[-]blocks_in_[y] = number of blocks in the Y direction (%d)\n" %
        blocks_in_y)
    sys.stderr.write("   -[-i]iteration = temporal iteration (%d)\n" %
                     iterationi)
    sys.stderr.write(
        "   -[-f]ile = name of the file with the motion fields (\"%s\")\n" %
        file)
    sys.stderr.write("   -[-p]ictures = number of pictures to process (%d)\n" %
                     pictures)
    sys.stderr.write(
        "   -[-t]ermporal_levels = number of temporal levels (%d)\n" %
        temporal_levels)


ifdef({{DEBUG}}, display.info(str(sys.argv[0:]) + '\n'))

## Define the variable for options.
opts = ""

try:
    opts, extraparams = getopt.getopt(sys.argv[1:], "x:y:i:f:p:t:h", [
        "blocks_in_x=", "blocks_in_y=", "iteration=", "file=", "pictures=",
        "temporal_levels=", "help"
    ])

except getopt.GetoptError, exc:
    display.info(sys.argv[0] + ": " + exc.msg + "\n")

for o, a in opts:
    if o in ("-x", "--blocks_in_x"):
示例#29
0
if args.SRLs:
    SRLs = int(args.SRLs)
if args.TRLs:
    TRLs = int(args.TRLs)

GOP_size = gop.get_size(TRLs)
pictures = GOPs * GOP_size + 1

# Ahora mismo solo implementa la extracción por niveles de resolución

# Procesamos las subbandas de alta frecuencia.
subband = 1
while subband < TRLs:

    ifdef({{DEBUG}},
    display.info(sys.argv[0] + ": processing high-pass subband " + str(subband) + " of " + str(TRLs) + "\n")
    )

    # Open the file with the size of each color image
    file_sizes = open ("tmp/" + HIGH + "_" + str(subband) + ".j2c", 'w')
    total = 0

    pictures = (pictures + 1) / 2

    image_number = 0
    while image_number < (pictures - 1):

        str_image_number = '%04d' % image_number

        # Y
        image_filename = HIGH + "_" + str(subband) + "_Y_" + str_image_number
    sys.stderr.write("\n")
    sys.stderr.write("  Description:\n")
    sys.stderr.write("\n")
    sys.stderr.write("   Compress the motion data.\n")
    sys.stderr.write("\n")
    sys.stderr.write("  Parameters:\n")
    sys.stderr.write("   -[-b]lock_size=size of the blocks in the motion estimation process (%d)\n" % block_size)
    sys.stderr.write("   -[-]block_si[z]e_min=minimal block size allowed in the motion estimation (%d)\n" % block_size_min)
    sys.stderr.write("   -[-p]ictures=number of images to process (%d)\n" % pictures)
    sys.stderr.write("   -[-]pixels_in_[x]=size of the X dimension of the pictures (%d)\n" % pixels_in_y)
    sys.stderr.write("   -[-]pixels_in_[y]=size of the Y dimension of the pictures (%d)\n" % pixels_in_x)
    sys.stderr.write("   -[-t]emporal_levels=number of iterations of the temporal transform + 1 (%d)\n" % "", temporal_levels)
    sys.stderr.write("\n")

ifdef({{DEBUG}},
display.info(str(sys.argv[0:]) + '\n')
)

opts = ""

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],"b:z:p:x:y:t:h",
                                      ["block_size=",
                                       "block_size_min=",
                                       "pictures=",
                                       "pixels_in_y=",
                                       "pixels_in_x=",
                                       "temporal_levels=",
                                       "help"
                                       ])
except getopt.GetoptError, exc:
示例#31
0
## Name of the file with the motion fields.
file = ""


## Documentation of usage.
#  -[-f]ile = Name of the file with the motion fields.
def usage():
    sys.stderr.write("+-------------------------+\n")
    sys.stderr.write("| MCTF motion_compress_cp |\n")
    sys.stderr.write("+-------------------------+\n")


## Define the variable for options.
opts = ""

try:
    opts, extraparams = getopt.getopt(sys.argv[1:], "f:h", ["file=", "help"])

except getopt.GetoptError, exc:
    display.info(sys.argv[0] + ": " + exc.msg + "\n")

for o, a in opts:
    if o in ("f", "--file"):
        file = a
        display.info(sys.argv[0] + ": file=" + file + '\n')
    if o in ("h", "--help"):
        usage()
        sys.exit()

os.system("cp " + file + " " + file + ".cp")
示例#32
0
    sys.stderr.write("   -[-]block_o[v]erlaping=number of overlaped pixels between the blocks in the motion estimation (%d)\n" % block_overlaping)
    sys.stderr.write("   -[-b]lock_size=size of the blocks in the motion estimation process (%d)\n" % block_size)
    sys.stderr.write("   -[-]block_si[z]e_min=minimal block size allowed in the motion estimation (%d)\n" % block_size_min)
    sys.stderr.write("   -[-l]layers=number of quality layers to decode (%d)\n" % layers)
    sys.stderr.write("   -[-p]ictures=number of images to process (%d)\n" % pictures)
    sys.stderr.write("   -[-]pixels_in_[x]=size of the X dimension of the pictures (%d)\n" %  pixels_in_x)
    sys.stderr.write("   -[-]pixels_in_[y]=size of the Y dimension of the pictures (%d)\n" %  pixels_in_y)
    sys.stderr.write("   -[-s]earch_range=size of the searching area of the motion estimation (%d)\n" % search_range)
    sys.stderr.write("   -[-]subpixel_[a]ccuracy=sub-pixel accuracy of the motion estimation (%d)\n" % subpixel_accuracy)
    sys.stderr.write("   -[-t]emporal_levels=number of iterations of the temporal transform + 1 (%d)\n" % temporal_levels)
    sys.stderr.write("\n")
    
opts = ""

ifdef({{DEBUG}},
display.info(str(sys.argv[0:]) + '\n')
)

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],"v:b:z:l:p:x:y:s:a:t:h",
                                      ["block_overlaping=",
                                       "block_size=",
                                       "block_size_min=",
                                       "layers=",
                                       "pictures=",
                                       "pixels_in_x=",
                                       "pixels_in_y=",
                                       "search_range=",
                                       "subpixel_accuracy=",
                                       "temporal_levels=",
                                       "help"
示例#33
0
    sys.stderr.write("   -[-]pixels_in_[x]=size of the X dimension of the pictures (%d)\n" % pixels_in_x)
    sys.stderr.write("   -[-]pixels_in_[y]=size of the Y dimension of the pictures (%d)\n" % pixels_in_y)
    sys.stderr.write("   -[-s]earch_range=size of the searching area of the motion estimation (%d)\n" % search_range)
    sys.stderr.write('   -[-]s[l]opes=distortion-length slope for each quality layer ("%s")\n' % slopes)
    sys.stderr.write(
        "   -[-]subpixel_[a]ccuracy=sub-pixel accuracy of the motion estimation (%d)\n" % subpixel_accuracy
    )
    sys.stderr.write(
        "   -[-t]emporal_levels=number of iterations of the temporal transform + 1 (%d)\n" % temporal_levels
    )
    sys.stderr.write("\n")


opts = ""

ifdef({{DEBUG}}, display.info(str(sys.argv[0:]) + "\n"))

try:
    opts, extraparams = getopt.getopt(
        sys.argv[1:],
        "v:b:z:d:p:x:y:l:p:a:t:h",
        [
            "block_overlaping=",
            "block_size=",
            "block_size_min=",
            "border_size=",
            "pictures=",
            "pixels_in_x=",
            "pixels_in_y=",
            "search_range=",
            "slopes=",
    sys.stderr.write("  Description:\n")
    sys.stderr.write("   Compress the LFB texture data.\n")
    sys.stderr.write("\n")
    sys.stderr.write("  Parameters:\n")
    sys.stderr.write("\n")
    sys.stderr.write("   -[-f]ile = file that contains the LFB data (\"%s\")\n" % file)
    sys.stderr.write("   -[-p]ictures = number of images to process (%d)\n" % pictures)
    sys.stderr.write("   -[-]pixels_in_[x] = size of the X dimension of the pictures (%d)\n" % pixels_in_x)
    sys.stderr.write("   -[-]pixels_in_[y] = size of the Y dimension of the pictures (%d)\n" % pixels_in_y)
    sys.stderr.write("   -[-s]lopes = distortion-length slope value for the only quality layer (%s)\n" % "", slopes)
    sys.stderr.write("   -[-t]emporal_levels = number of temporal levels (%d)\n" % temporal_levels)

opts = ""

ifdef({{DEBUG}},
display.info(str(sys.argv[0:]) + '\n')
)

try:
    opts, extraparams = getopt.getopt(sys.argv[1:],"f:p:x:y:s:t:h",
                                      ["file=",
                                       "pictures=",
                                       "pixels_in_x=",
                                       "pixels_in_y=",
                                       "slopes=",
                                       "temporal_levels=",
                                       "help"
                                       ])
except getopt.GetoptError, exc:
    sys.stderr.write(sys.argv[0] + ": " + exc.msg + "\n")
    sys.exit(2)
示例#35
0
def initialize():
    defaults = {
        "config_file"        : "defaults.conf",
        "devices_file"       : "devices.txt",
        "admin_username"     : "",
        "admin_password"     : "",
        "upgrade_url"        : "",
        "use-mgmt"           : False,
        "overwrite_bootimage": False,
        "print_version"      : False,
        "reboot"             : False,
        "set_bootimage"      : False,
        "verbosity"          : 0,
        "write_memory"       : False,
        "dry_run"            : False,
    }
    parameters = get_parameters_from_file(defaults)
    parameters = get_parameters_from_arguments(parameters)

    if parameters['print_version']:
        exit(0)

    if parameters['verbosity'] < 2:
        logging.captureWarnings(True)

    if not parameters['upgrade_url']:
        display.write("")
        display.write("  What is the URL for the upgrade file?")
        display.write(
                "    e.g. 'scp://*****:*****@servername/path/to/file'")
        parameters['upgrade_url'] = display.prompt("  > ")
        display.write("")
    # TODO: Better error handling with badly formed URLs
    try:
        url = get_uri_components(parameters['upgrade_url'])
    except:
        display.fatal("Do not recognize {} as a properly formatted URL!"
                      .format((parameters['upgrade_url'])))

    if not parameters['devices']:
        parameters['devices'] = get_devices_from_file(
                parameters['devices_file'])

    if parameters['verbosity'] > 0:
        display.info("Using enhanced display output.")

    if len(parameters['devices']) == 1:
        plural = ''
    else:
        plural = 's'
    display.info("Upgrade {} device{} to {}"
                 .format(len(parameters['devices']), plural, url['filename']))
    display.info("from {} using {}."
                 .format(url['servername'], url['protocol']))

    if parameters['use-mgmt']:
        display.info('Upgrade using the management interface.')

    if parameters['overwrite_bootimage']:
        display.info('Overwrite the currently running bootimage location.')
    else:
        display.info('Upgrading the backup/unbooted bootimage location.')

    if parameters['set_bootimage']:
        display.info("Mark the new image to be used during the next reboot.")

    if parameters['reboot'] or parameters['write_memory']:
        display.info('Save the current running configuration to NVRAM.')

    if parameters['reboot']:
        display.warn('Reboot devices following image upgrade.')

    if parameters['dry_run']:
        display.warn('Dry run option set, will not make any changes.')

    if not parameters['admin_username']:
        display.write('')
        parameters['admin_username'] = display.prompt("login: ")

    if not parameters['admin_password']:
        parameters['admin_password'] = getpass('Enter password for {}: '
                                         .format(parameters['admin_username']))

    display.write('')
    return parameters, url