diff options
| -rwxr-xr-x | lib/pb/generate.py | 3 | ||||
| -rwxr-xr-x | lib/pb/gradient.py | 15 | ||||
| -rwxr-xr-x | lib/pb/grid.py | 4 | ||||
| -rw-r--r-- | lib/server.py | 10 | ||||
| -rw-r--r-- | run_module_examples.py | 2 |
5 files changed, 23 insertions, 11 deletions
diff --git a/lib/pb/generate.py b/lib/pb/generate.py index a97970c..11df3b0 100755 --- a/lib/pb/generate.py +++ b/lib/pb/generate.py @@ -16,6 +16,7 @@ _COMPOSE_PARAMS = [ ] _DISPOSE_PARAMS = ["None", "Previous", "Background"] _DISPOSE_DEFAULT = "None" +_HUE_DEFUALT = '100'; class PbGenerate(Pb): #{{{ example params example_params = { @@ -79,7 +80,7 @@ class PbGenerate(Pb): 'contrast': {'type': 'int'}, 'saturation': {'type': 'int'}, 'rotate': {'type': 'int'}, - 'hue': {'type': 'int'}, + 'hue': {'type': 'int', 'default': _HUE_DEFUALT}, #ENUMS 'compose': {'type': 'enum', 'enum_values': _COMPOSE_PARAMS, 'default': 'Atop'}, diff --git a/lib/pb/gradient.py b/lib/pb/gradient.py index c2a9066..8f99a95 100755 --- a/lib/pb/gradient.py +++ b/lib/pb/gradient.py @@ -70,7 +70,7 @@ class PbGradient(Pb): 'default': DEFAULT_FINALFORMAT
},
'gradienttype': {'type':'enum', 'enum_values':[
- 'gradient', 'canvas', 'radial', 'colorspace',
+ 'gradient', 'canvas', 'plasma', 'radial', 'colorspace',
'mirrored', 'plasmawash', 'gradientwash', 'noise'
], 'default': 'gradient'},
'username': {'type':'string'}
@@ -79,7 +79,7 @@ class PbGradient(Pb): self.filename, self.filepath = self._filename_filepath_create()
- def _filename_create(self):
+ def _filename_create(self, **kwargs):
_base = "{}{}-{}_{}".format(
self.__class__.__name__,
str(self.params.color1).replace('#', '').replace('(', '-').replace(')', '-'),
@@ -113,6 +113,9 @@ class PbGradient(Pb): "radial" : [
"radial-gradient:{}-{}".format(self.params.color1, self.params.color2)
],
+ "plasma" : [
+ "plasma:{}-{}".format(self.params.color1, self.params.color2)
+ ],
"colorspace" : [
"-colorspace",
"Gray",
@@ -162,11 +165,15 @@ class PbGradient(Pb): if self.params.bevel: self._make_bevel()
def _get_bevelvalue(self):
+ sys.stderr.write("in the bevel function");
w, h = map(int, (self.params.width, self.params.height))
if h >= w:
- bevpercentval = str(int(self.params.percentbeveled)*0.005*int(h))
+ sys.stderr.write("In the first block")
+ bevpercentval = str(int(int(self.params.percentbeveled)*int(h))/500)
else:
- bevpercentval = str(int(self.params.percentbeveled)*0.005*int(w))
+ sys.stderr.write("In the second block")
+
+ bevpercentval = str(int(int(self.params.percentbeveled)*int(w))/500)
return {
"flatout": ["-s", bevpercentval, "-m", "outer"],
"flatinner": ["-s", bevpercentval, "-m", "inner"],
diff --git a/lib/pb/grid.py b/lib/pb/grid.py index d8b1aaa..8a59b83 100755 --- a/lib/pb/grid.py +++ b/lib/pb/grid.py @@ -39,7 +39,7 @@ class PbGrid(Pb): 'swing': {'type':'int'}, 'tilt': {'type':'int'}, 'roll': {'type':'int'}, - 'zoom': {'type':'int'}, + 'zoom': {'type':'float'}, 'skycolor': {'type':'color', 'default': 'transparent'}, 'transition': { 'type':'enum', @@ -51,7 +51,7 @@ class PbGrid(Pb): 'trim': {'type':'bool'}, 'finalformat': { 'type':'enum', - 'enum_values' :OUTPUT_IMAGE_TYPES, + 'enum_values': OUTPUT_IMAGE_TYPES, 'default': DEFAULT_FINALFORMAT }, 'username': {'type':'string'}, diff --git a/lib/server.py b/lib/server.py index 1218531..663fb4d 100644 --- a/lib/server.py +++ b/lib/server.py @@ -39,9 +39,13 @@ class Server(object): return "HELLO WORLD!" @self.app.route('/im/api/<pb_classname>', methods=['POST']) def pb(pb_classname): - host = request.headers.getlist("X-Forwarded-For")[0] - regex = re.compile(r'[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') - forwarded_ip = regex.search(host).group() + x_forwarded_headers = request.headers.getlist("X-Forwarded-For") + if x_forwarded_headers: + host = x_forwarded_headers[0] + regex = re.compile(r'[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') + forwarded_ip = regex.search(host).group() + else: + forwarded_ip = None return self._response_post( pb_classname, request.form.to_dict(), diff --git a/run_module_examples.py b/run_module_examples.py index 637fd81..4e59475 100644 --- a/run_module_examples.py +++ b/run_module_examples.py @@ -4,7 +4,7 @@ import sys sys.path.append('./lib') from pb import * for cls in Pb.__subclasses__(): - if cls.__name__ == "PbGenerate": + if cls.__name__ == "PbGradient": print cls.__name__ instance = cls.example_run() instance.file_s3move() |
