Permalink
Browse files

Add utilities to set avatar

  • Loading branch information...
1 parent e853ee3 commit 08eedbabce1a6e17a96655fe37f34b90b4dfaf07 @jvliwanag jvliwanag committed Oct 17, 2012
Showing with 69 additions and 0 deletions.
  1. +35 −0 bin/drawtext
  2. +34 −0 bin/oasetavatar
View
35 bin/drawtext
@@ -0,0 +1,35 @@
+#!/bin/env ruby
+
+require 'rubygems'
+require 'RMagick'
+include Magick
+
+if ARGV.length < 2
+ puts "Usage: drawtext TEXT OUTFILE"
+ exit 1
+end
+
+text = ARGV[0]
+out = ARGV[1]
+
+w = 200
+h = 200
+bg = "gray"
+
+
+fsize = 42
+
+f = Image.new(w, h) { self.background_color = bg }
+
+gc = Draw.new
+gc.fill = 'white'
+gc.stroke = 'none'
+gc.pointsize = fsize
+
+gc.annotate(f, 0, 0, 5, h/2, "AGENT")
+
+gc.fill = 'black'
+gc.annotate(f, 0, 0, 40, h/2 + fsize, text)
+
+f.write(out)
+exit
View
34 bin/oasetavatar
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'tempfile'
+
+load '~/conf/oadevenv.rb'
+
+if ARGV.length < 1
+ puts "USAGE: oasetavatar USER"
+ exit 1
+end
+
+user = ARGV[0]
+password = 'password'
+
+pic = Tempfile.new(['oapic', '.png'])
+pic.close
+
+`drawtext "#{user}" "#{pic.path}"`
+
+## Page browse
+
+main_p = login(user, password)
+info_p = main_p.link_with(:id => 'menu.myInformation').click
+
+upload_f = info_p.form_with(:id => 'upload')
+upload_f.file_upload.file_name = pic.path
+upload_f['uploadbutton'] = 'Upload'
+
+upload_f.submit
+
+## Cleanup -- better done within fixed scope
+
+pic.delete

0 comments on commit 08eedba

Please sign in to comment.