def run(self):
        loger = self.executor.log
        exec_dir = os.getcwd()
        is_valid, errors = self.validate_args()
        res = None
        if is_valid:
            res = self.value_substitutor.substitute(self.ConfigPath)
        else:
            raise InvalidCommandArgumentsError(str(errors))

        if not os.path.isabs(res):
            config_loader = self.executor.parent.config_loader
            dr = os.path.dirname(config_loader.config_file)
            res = os.path.join(dr, res)
        arguments = ["ExecuteHalConfig", "-from", "fs", res]
        arguments.append("-dir")
        arguments.append(exec_dir)
        if self.CustomVars:
            arguments.append("-custom-vars")
            arguments.append(self.CustomVars)
        if self.ExcludedBundles:
            arguments.append("-excluded-bundles")
            arguments.append(self.ExcludedBundles)
        if self.executor.verbose:
            arguments.append("-v")
        console_main(arguments, loger)
    def run(self):
        is_valid, errors = self.validate_args()
        if is_valid:
            for k in self.iterator_array:
                res = self.resource_format % k
                dest = self.destination_format % k
                res = self.value_substitutor.substitute(res)
                dest = self.value_substitutor.substitute(dest)
                rurl = replace_from_url(executor=self.executor,
                                        resources=self.resources,
                                        variables=self.variables,
                                        verbose=self.verbose)

                rtext = replace_text(executor=self.executor,
                                     resources=self.resources,
                                     variables=self.variables,
                                     verbose=self.verbose)
                match = "</Project>$"
                repl = "<ItemGroup><AndroidResource Include=\"" + dest.replace(
                    '/', "\\\\") + "\" /></ItemGroup>\n</Project>"
                rurl.set_args(res, dest)
                rtext.set_args(self.project_file, match, repl)
                rurl.run()
                rtext.run()
        else:
            raise InvalidCommandArgumentsError(str(errors))
Example #3
0
  def run(self):
    su = self.value_substitutor.substitute
    path_to_set = su(self.kwargs['PathToSet'])
    is_json = su(self.kwargs["ValueIsJson"]) in ['true', 'True', '1', 'Yes', 'yes', 'YES']
    json_file = su(self.kwargs['File'])
    value = su(self.kwargs['Value'])
    destination_json = su(self.kwargs['Destination'])
    is_valid, errors = self.validate_args()
    if is_valid:
      to_repl = value
      if is_json:
        to_repl = json.loads(to_repl)
      j = json.loads(codecs.open(json_file, 'r', 'utf-8').read())
      if path_to_set in j:
        j[path_to_set] = to_repl
      elif '=>' in path_to_set:
        elements = path_to_set.split('=>')
        subel = j
        for i in range(0,len(elements)):
          el = elements[i]
          if isinstance(subel, list):
            el = int(elements[i])
          if i+1 == len(elements):
            subel[el]=to_repl
          else:
            subel = subel[el]

      with codecs.open(destination_json, 'w', 'utf-8') as f:
        f.write(json.dumps(j, indent=2, sort_keys=True))
        f.close()
    else:
      raise InvalidCommandArgumentsError(str(errors))
Example #4
0
    def run(self):
        is_valid, errors = self.validate_args()
        if is_valid:
            self.img_res = self.value_substitutor.substitute(self.img_res)
            if self.img_res.startswith('file://'):
                self.img_res = self.img_res[7:]

            self.dest = self.value_substitutor.substitute(self.dest)

            self.img_res = self.img_res.replace('./', '')
            self.format = self.value_substitutor.substitute(self.format)

            if self.resolution:
                self.resolution = self.value_substitutor.substitute(
                    self.resolution)
            self.log.write('\n'.join([
                self.img_res, self.dest, self.format, self.resolution or '?X?'
            ]))
            img = Image.open(self.img_res)
            if self.resolution:
                print self.get_resolution_set()
                img = img.resize(self.get_resolution_set(), Image.ANTIALIAS)
            img.save(self.dest, self.format)
        else:
            raise InvalidCommandArgumentsError(str(errors))
 def run(self):
   is_valid, errors =  self.validate_args()
   self.StringMatch = self.value_substitutor.substitute(self.StringMatch)
   self.FileMatch = self.value_substitutor.substitute(self.FileMatch)
   self.ReplaceWith = self.value_substitutor.substitute(self.ReplaceWith)
   if is_valid:
     return self.__mass_replace__(self.FileMatch, self.StringMatch, self.ReplaceWith)
   else:
     raise InvalidCommandArgumentsError(' AND '.join(errors))
 def run(self):
     is_valid, errors = self.validate_args()
     if is_valid:
         print self.expression
         result = eval(self.expression)
         if result:
             self.executor.execute_bundle_within_current_scope(self.bundle)
     else:
         raise InvalidCommandArgumentsError(str(errors))
 def run(self):
   is_valid, errors = self.validate_args()
   su = self.value_substitutor.substitute
   if is_valid:
     r = filter(lambda x: x['name']==su(self.kwargs['Variable']), self.executor.bundle_vars)
     if r:
       r[0]['value'] = su(self.kwargs["NewValue"])
     else:
       self.executor.bundle_vars.append(HalVar.from_dict({'name':su(self.kwargs['Variable']), 'value':su(self.kwargs["NewValue"])}))
   else:
     raise InvalidCommandArgumentsError(str(errors))
 def set_args(self, **kwargs):
     self.kwargs = kwargs
     is_valid, errors = self.validate_args()
     if is_valid:
         self.command = self.kwargs["command"]
         self.is_sudo = self.kwargs["is sudo"]
         self.catch_shell_output = bool(kwargs["catch shell output"])
         self.working_dir = self.kwargs["working directory"].startswith("/") and self.kwargs["working directory"] or \
                            os.path.join(os.getcwd(), self.kwargs["working directory"])
     else:
         raise InvalidCommandArgumentsError(str(errors))
 def run(self):
     is_valid, errors = self.validate_args()
     res = None
     if is_valid:
         res = self.value_substitutor.substitute(self.ConfigPath)
     else:
         raise InvalidCommandArgumentsError(str(errors))
     if not os.path.isabs(res):
         config_loader = self.executor.parent.config_loader
         dr = os.path.dirname(config_loader.config_file)
         res = os.path.join(dr, res)
     loader = FileConfigLoader(res)
     config = loader.load_config()
     builder = self.executor.parent
     bundles_filter = ConfigBuildFilter()
     builder.apply_parametrized(config, bundles_filter=bundles_filter)
Example #10
0
 def run(self):
     is_valid, errors = self.validate_args()
     if is_valid:
         if not self.array.startswith('[') or not self.array.endswith(']'):
             self.array = '[' + self.array + ']'
         result = eval(self.array)
         index = 0
         for k in result:
             self.bundle["Variables"] = [{
                 'name': 'item',
                 'value': str(k)
             }, {
                 'name': 'index',
                 'value': str(index)
             }]
             self.executor.execute_bundle_within_current_scope(self.bundle)
             index += 1
     else:
         raise InvalidCommandArgumentsError(str(errors))
Example #11
0
      f = urllib2.urlopen(res)
      dest = self.destination
      if not dest.startswith('/'):
        if not dest.startswith('./'):
          dest = './'+dest
      dest = os.path.abspath(dest)
      fh = None
      ex_raised = None
      try:
        if not os.path.exists(dest):
          open(dest, 'a').close()
        fh = open(dest, 'wb')
        fh.write(f.read())
      except Exception, ex:
        ex_raised = ex
      finally:
        if fh:
          fh.close()
        if ex_raised:
          raise ex_raised
      print 'Downloaded the file to ', self.destination
    else:
      raise InvalidCommandArgumentsError(str(errors))


__plugin__ = ReplaceFromUrl

def test_replace_from_url():
  rfu = ReplaceFromUrl(verbose=True)
  rfu.set_args()
 def run(self):
     is_valid, errors = self.validate_args()
     if is_valid:
         self.log.write(self.value_substitutor.substitute(self.texttoprint))
     else:
         raise InvalidCommandArgumentsError(str(errors))