Tap chi Open source for you,tap chi danh cho lap trinh ios,android 2014 giup ban tim hieu ve ma nguon mo Tap chi Open source for you,tap chi danh cho lap trinh ios,android 2014 giup ban tim hieu ve ma nguon mo
Trang 1THE COMPLETE MAGAZINE ON OPEN SOURCE
Trang 3Double Road Indiranagar
2nd stage, Bangalore -560038
Trang 435 Building Web Applications
Using the Python Flask
Mi-croframework
39 IBM Worklight A Mobile App
Development Platform
44 What’s the Android Open
Ac-cessory Protocol All About?
49 An Introduction to Haskell
classes and User Defined
Data Types
53 How to Contribute to GNOME
57 Grails: An Agile and Friendly
Framework
62 Getting Started with Clojure
65 Mobile Applcation Testing
Tools: You Should Know About
ADmin
70 Send Bulk Mail Without
Be-ing Treated Like a Spammer
75 Is Your Network Getting
Slower?
79 Use LimeSurvey for an
Extraordinary Surveying
Experience
81 Make Your Own PBX with
Asterisk: A Collage of
Multi-ple Hardware Equipment
For YoU & me
48 Case Study: Unotech helps
Mahindra & Mahindra
Financial Services Limited
to optimize 87 per cent of its
proprietary field force
solu-tions costs
Contents
REGULAR 08 You Said It FEATURES
09 Offers of the Month
Trang 7Feature Enhancements
Infrastructure Enhancements
Touch client for tablets
and smartphones:
Offline Web client:
The secure, HTML5 mobile web
application provides a device-specific
user experience for Android and iOS
devices The Zimbra touch client can
be tailored through open APIs and
fully white labeled It delivers anytime,
anywhere mailbox access, through a
unique Zimbra experience, that keeps
people connected to their data
Offline Web client support for Chrome
and Firefox keeps Zimbra users
connected, even when not taking
advantage of native HTML5 data
storage support Users get the
ability to work offline with access to
one month’s worth of data And, IT
administrators benefit from an offline
client that doesn’t increase the cost
or management associated with a full
desktop client
Exchange Web Services:
Zimbra Social integration:
Zimbra Connector for Microsoft Outlook (ZCO)
ActiveSync Performance and Scalability Enhancements
Free trial, visit www.zimbra.com
Document preview:
Active-active:
The latest release adds new Exchange
Web Services (EWS) support,
enabling all mail, contacts, tasks and
calendar functionality in Outlook for
Mac Administrators can add Outlook
for Mac to the list of supported clients
for BYOD environments, and users
get to choose whatever Mac desktop
client they prefer
High fidelity document preview is now available, allowing users to preview documents in their Web browser
Active-active is part of a release effort to increase Zimbra Collaboration’s scale and performance capabilities in complex Zimbra deployments This encompasses
multi-a number of enhmulti-ancements to the web application and server architecture, and introduces support for MariaDB Zimbra Collaboration 9.x will continue this investment, helping eliminate downtime due to upgrades, maintenance or unplanned outages
Zimbra Collaboration 8.5 includes integrated support for Zimbra Social
Customers running both Zimbra products benefit from a shared user experience and single sign-on
Keeping employees connected to all
of the collaboration touch points
The Zimbra Connector for Microsoft
Contact sales at +91 20 6730 4731
Service providers running large-scale ActiveSync deployments will benefit from decreased computing resource costs and increased user density per server Administrators can now add BlackBerry 10 devices to the list of ActiveSync-enabled devices that are supported for BYOD environments.I’m very excited about what we are building at Zimbra and, with the addition of the Mezeo platform to the product portfolio, there will be some great product updates and advancements integrating sync and share into your daily work life, down the road
Outlook (ZCO) provides real-time, two-way syncing of mail, contacts, tasks and calendars between Outlook and Zimbra The latest release adds support for traditional Chinese and improvements for system administrators including: syncing, connection security and share message support Administrators can better support and troubleshoot issues with logging improvements Users can now accept shared mail folders and calendars from Outlook without opening the Zimbra Web client and will notice improved performance when syncing a large number of messages
Zimbra Releases 8.5 Version
Collaboration
Anytime, Anywhere, Any Device
New Feature Highlights
Trang 8YOU SAID IT
Contributing content
I started using CentOS 7 as my primary OS, thanks to
the previous issue of OSFY in which you shipped the CentOS 7
DVD I was able to tweak it to my liking, the details of which I
have included in my blog: priteshugrankar.wordpress.com Also,
I have always wanted to try out GIT and was not able to set it up
the first time I tried This time though, it worked fine and I was
wondering if you would be interested in publishing an article on
installing and setting up GIT on CentOS 7, which I plan to write
Kindly let me know Is there a way that my blog articles could be
published in the magazine (online or offline versions)?
—Pritesh Ugrankar;
pritesh.ugrankar@gmail.com ED: Thank you for writing in to us We are glad that our DVD
could help you use CentOS 7 Thank you for including it in your
blog too We always welcome open source enthusiasts who want
to contribute content to our magazine In order to submit an
article to us, you will have to first send us a detailed Table of
Contents (ToC) and once it is reviewed by our team, you can go
ahead with the write-up You can find our editorial guidelines at
http://www.opensourceforu.com/write-for-linux-for-you/ for your
reference Please feel free to get back to us in case of any other
queries; we're always happy to help!
Query regarding Linux kernel support for
file systems
I read the August 2014 issue of OSFY On Page 26 (‘An
Introduction to The Linux Kernel’), the last line reads, “The
Linux kernel supports all major file systems including MS
Windows' NTFS." Yes, it's true! But does the Linux kernel
support the new ExFAT file systems? In my personal experience,
it does not I've a 64GB USB 2.0 pen drive (Transcend), and
when I used it in Windows XP, I was unable to format it in FAT32
but could do so in NTFS, and NTFS alone But, when I used the
same pen drive in my sister's laptop which runs on Windows 7, I
was able to format it in two versions - NTFS and ExFAT
I've my own reasons to believe that ExFAT is a newer version file system On my sister’s laptop, the hard disk's second partition of 480GB was formatted in ExFAT too! After putting the photos into her hard drive, I formatted my 64GB pen drive in her laptop —in the ExFAT file system I was able to access the pen drive on her laptop (running on MS Windows 7), but the pen drive was not accessible on both my desktop (running on MS Windows XP) and my laptop running
on Ubuntu 13.10 The pen drive was actually detected only
on the XP system, but was not accessible A message came
up saying that I must format it before I can use it Please look into this new format too
—Mathew John Kurian;
nkmathewjohn@gmail.com ED: Thank you for your query We have forwarded your email
to the author of that article and we are forwarding this request
to the other authors who write for us in order to come out with a write-up featuring more information on the different file systems.
Setting up a proxy server
I am trying to open a small office and plan to use five computer systems I would like to set up a proxy server to share the broadband connection in the office and also to restrict access to certain social media websites How am I supposed
to go about this? Kindly note that my financial resources are limited An early reply would be very helpful
—Tamit Das Sharma;
official.tamitdassharma@gmail.com ED: You can set up a Squid caching proxy server which will
help you in achieving what you want To configure it, you can refer to the link below:
http://www.squid-cache.org/
You can also install and use firewalls like IPCop and pfSence to share and restrict access to the Internet
Trang 9THE monTH
No condition attached for trial of our cloud platform
(Free Trial Coupon)
Enjoy & Please share Feedback at sales@cloudoye.com
For more information, call us on 1800-212-2022 / +91-120-666-7718
www.cloudoye.com www.esds.co.in
Get 25%
Off
Considering VPS or a Dedicated Server? Save Big !!! And go with our ProX Plans
Time to go PRO now
25% Off on ProX Plans - Ideal for running High Traffic or E-Commerce Website Coupon Code : OSFY2014
Register in Advance to receive a special discount
EMBEDDED SOFTWARE DEVELOPMENT COURSES AND WORKSHOPS
Faculty - Babu Krishnamuthy
Visiting Faculty/ CDAC/ACTS Porting Embedded RTOS to an ARM platform
Dates : October 11 and 12 ( 2 days program )
CDAC Alumni will get a special rate if registered in advance -please write to
babu_krishnamurthy@yahoo.com
mentioning the CDAC/ACTS center
School of Embedded Software Development Venue: Malleshwaram, Bangalore
Date: 27th, 28th Sept & 4th, 5th, 11th, 12th
18th & 19th October2014
Time: 10.00 am to 02.00pm (4 hrs.) per day Qualification: Degree / Diploma Trainging Contents: Introduction, HDFS
Maoreduce, Administration, Hbase, Hive, Pig Sqoop, Flume, Oozie, Hadoop2.0
using hadoop eco-system
Rs.6742/-(inclusive of service tax) per delegate
Certificates
Will Be
Awarded
Trang 13IBM brings Linux to its Power
System servers
IBM has installed Linux on its Power System servers in the company’s 54 centres
across the globe Earlier
this year, the company
announced plans of
investing billions of dollars
on the Linux platform IBM
will be training developers
to build applications on
Linux systems Developers
can use Ubuntu, Red Hat
Linux and SUSE Enterprise
Server to access parallel processing and virtualisation features
IBM also announced a few new services recently at LinuxCon, which
are expected to be run on the Power Server environment The OpenPower
Foundation has made Power System architecture open source Developers can
access the source code for the software and designs for hardware solutions
These services are better than generic servers in data centres IBM claims that
they are the best tools for data analytics and cloud computing These services
will help IBM to expand Power System expertise in various sectors IBM can
finally focus on the untapped market segment of high performance, efficient and
effective big data analytics This move will also reduce the use of software and
hardware resources at data centres
Ubuntu Installer bug formats the entire hard drive!
Installing a new OS on
your PC is never a
risk-free task There is always
a huge threat to your data
Hence, it’s recommended
that you back up your hard
drive before installing
any OS Many users have
filed reports regarding the
‘Reinstall Ubuntu’ option in
the Ubuntu Installer over the
past one year According to
these reports, the ‘Reinstall
Ubuntu’ option secretly wipes the data in other partitions of the hard drive It
also wipes out recovery images and other operating systems This option is
supposed to overwrite the existing Ubuntu installation only Ubuntu Installer
warns users that it will delete all Ubuntu programs, documents, photos, music
and any other files, which creates confusion since users think that it will delete
the data residing only on Ubuntu Hence, there is the need for a clear warning
from Ubuntu Installer to avoid losing data
The MIPS Creator CI20 board, a Raspberry Pi-like
dev board for hackers
There is a new entry among open source developers’ boards—the MIPS
FOSSBYTES
LibreOffice 4.3.1 released with 100 bugs fixed
The free, power-packed, open source, personal productivity suite called LibreOffice has been updated to a new version and it’s ready for use on Windows, Mac OS and Linux The release of LibreOffice 4.3.1 has been announced by The Document Foundation (TDF) With this new update, 100 bugs have been fixed successfully These fixes include RTF improvement, enhancement
to OOXML file handling, and improvement in both RTF and OOXML files import The background colour of the Writer word processing app has been slightly lightened and also improved for overall stability and performance Two essential security patches have been included and they have been back-ported to the older 4.2.x series This updated version includes six feature-rich applications: Writer, Calc, Impress, Draw, Math and Base
Easily add videos to WordPress with the new VideoNab plugin
PaperTelevision—one of the many ups emerging from Cincinnati, Ohio in the US—has proudly announced a new WordPress plugin titled VideoNab Yes, they seem to be fond of mashing two words together and randomly capitalising letters in order to form a new word VideoNab is a powerful WordPress plugin that scours YouTube for videos on any topic Though the results are spectacular, the concept itself is simple: set the topic, choose a schedule for how often new videos are ‘nabbed’, and VideoNab’s filtering and aggregation software handles the rest Set it, forget it, and the site
start-is suddenly an automated machine of constant, fresh video content Users can refine the settings to include comments for each video, design customisations, share them across all social media, and even use
an integrated voting system — a nice touch for hosting contests, or simply allowing visitors to rate their favourite videos
Powered by www.efytimes.com
Trang 14Calendar of forthComing events
Name, Date and Venue Description Contact Details and Website Gartner Symposium IT Xpo,
October 14-17, 2014; Grand Hyatt, Goa
CIOs and senior IT executives from across the world will gather at this event, which offers talks and workshops on new ideas and strate- gies in the IT industry.
Website:
http://www.gartner.com
Open Source India, November 7-8, 2014;
NIMHANS Center, Bengaluru
Asia’s premier open source conference that aims to nurture and promote the open source ecosystem across the sub-continent.
Omar Farooq; Email: omar.farooq@ efy.in; Ph: 09958881862 http://www.osidays.com CeBit
November 12-14, 2014;
BIEC, Bengaluru
This is one of the world’s leading business IT events, and offers a combination of services and benefits that will strengthen the Indian IT and ITES markets.
Website:
http://www.cebit-india.com/
5th Annual Datacenter Dynamics Converged;
December 9, 2014; Riyadh
The event aims to assist the community in the datacentre domain by exchanging ideas, accessing market knowledge and launching new initiatives.
Praveen Nair; Email: Praveen.nair@ datacenterdynamics.com; Ph: +91 9820003158; Website:
Website:
http://www.hostingcon.com/ contact-us/
Creator CI20 Imagination Technologies has launched
an ISA developer board similar to the Raspberry Pi and BeagleBone Black SBCs
Creator is Imagination’s new program, which will help it to provide low cost development systems for use to the open source community—to enthusiasts, hobbyists, cross-platform developers (i.e., Arduino), and partners looking to create applications using IP technologies Creator CI20 SBC is powered by the 1.2GHz Ingenic JZ4780 system chip along with a PowerVR SGX540 GPU and 1GB of DDR3 RAM It comes with 8GB of NAND flash storage as an option and an SD card slot for expandable memory support The board comes with a 10/100 Ethernet port, Wi-Fi and Bluetooth connectivity, USB OTG support, a HDMI port and CMOS camera input The board’s dimensions are just 90.2mm x 95.3mm
Mozilla Firefox 32 arrives with better SSL security features
Mozilla has announced the release of Firefox
32, which means users of the open source Web browser can now access new security fixes and features Firefox 32 supports public-key pinning This feature provides better security for Secure Sockets Layer (SSL) certificate authentication The latest feature
in the new version of Firefox combines with other mechanisms, which are used by Web browsers to enhance the integrity and authenticity of SSL certificates
Akamai warns of IptabLes and
and securing online content and business
applications Through the company’s
Prolexic Security Engineering & Research
Team (PLXsert), it has released a new
cyber security threat advisory that alerts
enterprises to a high-risk threat of IptabLes
and IptabLex infections on Linux systems
People with malicious intentions could use
infected Linux systems to launch distributed
denial of service (DDoS) attacks against the
entertainment industry and other verticals
DDoS botnet threat to Linux systems:
The mass infestation of IptabLes and
IptabLex seems to have been driven by a
large number of Linux-based Web servers
being compromised, mainly by exploiting
Apache Struts, Tomcat and Elasticsearch
vulnerabilities Attackers have used the
Linux vulnerabilities on unmaintained
servers to gain access, escalate privileges to
allow remote control of the machine, and
then drop malicious code into the system and
run it As a result, a system can be controlled
remotely as part of a DDoS botnet A
post-infection indication of an attack is a payload
named IptabLes or IptabLex located in the
/boot directory These script files run the
.IptabLes binary on reboot The malware also
contains a self-updating feature that causes
the infected system to contact a remote host
to download a file In the lab environment, an
infected system attempted to contact two IP
addresses located in Asia
Asia apparently a significant source
of DDoS attacks: Command and control
centres (C2, CC) for IptabLes and
IptabLex are currently located in Asia
Infected systems were initially known to
be in Asia; however, more recently, many
infections have been observed on servers
hosted in the US and in other regions
In the past, most DDoS bot infections
originated from Russia, but now Asia
appears to be a significant source of such
infections
Trang 15Nr Bharat Petrol Pump, Ghyaneshwer
Paduka Chowk, FC Road, Shivajinagar
1176, 12th B Main,HAL 2nd Stage, Indiranagar,Bangalore - 560008, India
Lt Col Shaju N T
+91-9611192237info@asterisk-training.comwww.asttecs.com,www.asterisk-training.com
Produced Highest number ofRed Hat professionals
in the world
Merchant'sAssociation Building, M.L Road,Kottayam - 686001,
Kerala, India
Courses Offered:
Address (HQ):
GRRASLinuxTrainingandDevelopmentCenter
Courses Offered: RHCE, RHCSS, RHCVA,
CCNA, PHP, Shell Scripting (online training
GRRAS Linux Training and
DevelopmentCenter, 219, Himmat Nagar,
Behind Kiran Sweets, Gopalpura Turn,
Tonk Road, Jaipur, Rajasthan,India
A prominent player in Open SourceTechnology
1 & 2 , 4th Floor,Jhaver Plaza, 1A NungambakkamHigh Road, Chennai - 600 034, India
Ms Rema+91-9840982185enquiry@vectratech.inwww.vectratech.in
635, 6th Main Road,Hanumanthnagar,
Bangalore - 560 019, India
Mr Ramesh Kumar+91-80-22428538,
26780762, 65680048 /+91-9845057731, 9449857731info@linuxlearningcentre.comwww.linuxlearningcentre.com
North Kolkata, 2/80Dumdum Road, Near DumdumMetro Station, 1st & 2nd Floor,Kolkata - 700074
Mr Tuhin Sinha+91-9830075018,9830051236
sinhatuhin1@gmail.comNorth & South Kolkatawww.aemk.org
2-88, 1st floor,Sai Nagar Colony, Chaitanyapuri,Hyderabad - 060
Mr Amit+91-9030450039,+91-9030450397
info@duestor.comwww.duestor.com
www.ipsr.org
Linux Training & Certification
RHCSA,RHCE, RHCVA, RHCSS,
NCLA, NCLP, Linux Basics,
Shell Scripting,
(Coming soon) MySQL
104B Instant Plaza,
Behind Nagrik Stores,
Near Ashok Cinema,
Thane Station West - 400601,
Trang 16Mozilla has provided long-term support to Online Certificate Status Protocol (OCSP), which is used to check with a CA on the status of a given certificate OCSP Stapling, an extension of OCSP, accelerates the SSL certificate status-checking process Moreover, to improve security, Firefox 32 doesn’t contain a number of 1,024-bit trust certificates from the browser Additionally, Mozilla has also issued six security advisories for vulnerabilities Three of them are quite critical Details of the memory-corruption vulnerabilities have been provided by the Mozilla Foundation Security Advisory (MFSA) 2014-67 A researcher who has been working with Hewlett-Packard’s Tipping Point Zero Day Initiative (ZDI) has been credited with reporting a use-after-free memory issue (identified as MFSA 2014-72) This, in particular, was caused by setting the direction of text on a page
Chrome 38 brings a new responsive image element called ‘Picture’
The pictures and photographs on websites, known as simple images, are all static images But Google’s Chrome 38 is
set to change this old concept with a new responsive element called ‘Picture’ This would introduce a new responsive design to the website, which renders and scales the elements on the Web page in the appropriate format for the screen size HTML 5.1 has replaced image tag with the superset element for image containers Google’s
‘Picture’ element is based on this technology in W3C HTML 5.1 Some Linux distributions like Ubuntu, Fedora, openSUSE, Debian and Red Hat already have 64-bit beta channel support but for the Mac, this will be the first browser
to provide a 64-bit build Currently, Mac users can run the Canary branch
of Chrome to get a 64-bit version of Chrome This new 64-bit build of Chrome for the Mac should bring the most stable and usable Web browser
to the Mac platform The Chrome 37 64-bit build for Windows is supposed
to release in the same week
CoreOS announces free availability of its Docker-focused Linux distribution
Last year, Docker emerged as one of the most discussed virtualisation technologies But running
Docker requires much effort
CoreOS has announced that its Docker-focused Linux distribution is now available for free as an image that can
be deployed on the popular DigitalOcean cloud service
It also lowers the barrier to entry, and the cost for setting
up the Docker and running it
India-based start-up
launches maiden Linux
container-sharing website
Flockport, a start-up based in Mumbai,
announced the launch of Flockport
com, which is the first Linux container
(LXC) sharing website that will offer
users popular Web applications in
portable containers Users will get
cloud-like flexibility of application
instances, which can be deployed
on demand Users and developers
accessing this website will be able to
download and share LXC containers; a
Flockport Utility will also be provided
to set up LXC for users, who will
be allowed to view and download
Flockport containers directly to
their systems A fast improving
technology, Linux containers provides
all the benefits of virtualisation
without any performance penalty
Containers are portable and they can
be cloned, backed up, launched and
also deployed across environments
This opens up a world of flexibility
for application developers and
users Unlike preceding container
technology, Linux containers pave the
way for widespread adoption There
is a significant information gap on
LXC in the marketplace, which has
to be addressed by Flockport This is
a free service and users will also be
allowed to deploy containers directly
to the cloud This will help public
cloud providers broaden their market
base by allowing customers to deploy
complex applications in seconds
Trang 17DigitalOcean is one of the fastest growing cloud vendors and offers services
for just US$ 5 a month It runs on fast solid state drives (SSDs)
In March this year, DigitalOcean had announced a round of funding that
brought in US$ 37.5 million from investors Droplets are deployed by users
as virtual instances of operating systems The new partnership has brought out
the CoreOS as an image, which DigitalOcean customers can easily deploy as
a Droplet This partnership between CoreOS and DigitalOcean does not have
a specific revenue target
Blivet-gui–the new partition manager for Fedora
The next-gen partition
manager for Fedora
has been announced
by developer Vratislav
Podzimek and it’s called
Blivet-gui This version
is going to replace
Gparted, which is the
most popular
GUI-based partition manager
found in all major
distros The new
Blivet-gui is based on the
Blivet Python library,
which was originally Anaconda’s storage management and configuration
tool This new partition manager was required as none of the existing GUI
partitioning tools support all the modern storage technologies Fedora’s
Anaconda base has support for all and has been chosen as the back-end for
the new tool The application has been out for just a few months now and it
looks to be quite interesting and useful More developments are awaited on
features like RAID and BTRFS support
The other developer working on this project is Vojtech Trefny Gparted’s
look and feel is closely followed in this new version so that users get a familiar
interface Tasks are also handled almost in the same way as tasks are added, one
by one, and then the ‘Apply’ button is pressed The features that have already
been implemented are: visualisation of storage devices; and creating, editing
and deleting disk partitions
The city of Turin to dump Windows XP and switch to Ubuntu
The city of Turin’s municipality is hoping to save 6 million Euros in five
years, as it has decided to switch to Ubuntu Linux from Windows XP, across
all its offices This means that the open source operating system will be
installed on 8,300 PCs This move will generate an immediate savings of
approximately € 300 per machine This amount will grow over the years
as there will no longer be any need for the renewal of proprietary software
licences The employees will also get used to the new machines, with time
There is another reason behind this switchover The computers currently
in use in Turin’s municipal offices are quite old and might not be able to
efficiently support Windows 8 on them Linux offers more flexibility with
older machines Windows XP support officially ends this year In early
August, the switch to Ubuntu was officially approved and it will take
one-and-a-half years to complete the changeover
Avnet releases Linux-ready
‘PicoZed’ COMs
An array of four Linux-ready ‘PicoZed’ COMs has been released by Avnet
These are based on Xilinx’s
Zynq-7000 SoCs and integrate dual ARM Cortex-A9 cores with FPGAs Avnet has delivered a true COM without the real-world Ethernet and USB ports The basic design supports Linux on a variety
of Xilinx Zynq-7000 system-on-chips Avnet has spun off different versions
of the MicroZed for several Zynq-7000 models But this PicoZed is a single board which offers pin compatibility with a greater range of Zynq SoC variants PicoZed is offered in versions that are based on Zynq-7010, -7015, -7020, and -7030 SoCs
PicoZed is aimed at industrial controls, embedded vision, test and measurement, motor controls, and software-defined radio applications
It offers functions like memory, configuration, Ethernet, USB, clocks and power Most of PicoZed’s programmable logic I/O is expressed via a Low-Pin Count (LPC) FMC connector Zynq models also differ in the tightly linked FPGA subsystem and it offers 53,200 look-up tables (LUTs) All four versions provide access to over 100 user I/O pins through three I/O connectors on the rear of the module for connecting Ethernet, USB, JTAG, power and other control signals According to Avnet, the four serial transceivers on the Zynq-
7015 and -7030 based PicoZeds are allocated to a PCI-Express x1 (Gen2) card edge interface, as well as the FMC connector, an SFP+ cage, and a general-purpose SMA interface
Trang 18affordable price point, in order to get more people to indulge in their craving for bold, big-screen entertainment at home Packed with an assortment of advanced features and Hitachi’s unparalleled technology and reliability, our designers have ensured that this projector truly enhances the entertainment experience — presenting movies, sports and video games in a way that one has never seen before.”
Acer believes in giving the best support to its customers Kumar explains, “We first try and understand the requirements of our customer,
as we just don’t want to sell a product Rather, we want to help a customer buy a product We ask a few questions before selling our product—whether the customer is looking for a home theatre, what the room’s dimensions are, the resolution or brightness required, etc.”
To help you decide on what you need, here are a few factors to keep in mind
Specifications: If you’re a technical person, you will know
the kind of specifications required for your projector But if you are not, you will have to research a bit on that too Specifications would include a few factors that are listed below
Dimensions: The dimension of the room in which you plan to
place your projector Projectors have different configurations to suit the dimensions of a place
Size: Projectors now have a wide range in shapes and sizes as well Wireless or wired: Both wireless and wired projectors are now
available If you are planning to buy one for your home, you may
be comfortable with the wired version but if you’re looking for a projector in your meeting room then a wireless projector might be more appropriate
Resolution: This is the number of pixels used to display an
image If the projector has a higher resolution, it uses more pixels
to create the image, which results in a cleaner, sharper and crisper image A high resolution will be necessary if the projector is intended for classrooms or meeting rooms as it will help to project charts, texts and graphs more clearly
Colour brightness or lumens: Select the level of brightness
based on the room’s dimensions The brightness of a projector
is measured in lumens For homes, you would need nearly
1500 lumens, and for classrooms and conference rooms, you would need a minimum of 2500 lumens For larger spaces like auditoriums, you would need even higher lumens
Distance and positioning: This refers to the distance between
the projector and the screen The position of the projector and the dimensions of the room or hall will determine the size of the image projected You would need to look for the features that offer flexibility in placement
Looking for a projector for the classroom, home theatre, meeting room, auditorium or
even for gaming? Here’s a guide that helps you decide between the huge variety of
models, as well as a wide range of technologies, shapes and sizes.
Projectors are no longer used only in those stylish meeting
rooms People are now also replacing their huge LCD and
plasma screens with these reflectors And gone are the days
when they were categorised based on their weight Technology
has changed all that! Saji Kumar, director, product management,
Acer India, explains, “Earlier, we used to bundle projectors with
other key products as there was not much demand for them Now
we see so many requirements for projectors coming from various
segments that we have dedicated manpower for this product
It has become a key product like desktops and laptops.” Apart
from Acer, there are other brands like Hitachi that offer a variety
of technologically advanced projectors Tarun Jain, country
head, Hitachi Home Electronics India, says, “Hitachi offers a
comprehensive range of projectors, designed to suit varied space
and projection needs Whether it is maximising screen size in a
small room, limiting shadowing and glare, or maximising image
quality in a large space, we have a projector for every purpose.”
Comparing DLP-based projectors with
LCD versions
Projectors can be best described as inverted cameras which,
instead of receiving light, emit it out of the lens They fall into two
broad categories, LCD- and DLP-based LCDs represent an old
technology and the first projector ever launched was a LCD version
With time, the use of DLP projectors has become more widespread
There are many leading players in the market including Acer,
Hitachi and BenQ, and most of them offer DLP projectors Saji
Kumar states, “We focus on DLP projectors as it accounts for 60-65
per cent of the market.” DLP or digital light processing projectors
use a type of MEMS (microelectromechanical systems) technology
with a digital micro-mirror device These projectors are used in
a variety of display applications, ranging from traditional static
displays to interactive displays They are also used in non-traditional
applications like the security, medical and industrial domains
Factors you should consider when
buying a projector
Buying a projector is a major decision and there are many factors to
keep in mind when doing so Potential buyers should be very clear
about what their requirements are and then thoroughly research
what the market offers, as a projector is an expensive product to
acquire This is where companies shoulder a big portion of the
responsibility of ensuring buyers pick up the right product Says
Jain, “We have deliberately introduced this product at an extremely
the ‘Perfect’ Projector
Trang 19 Brightness: 3000 ANSI
Native resolution: XGA
Key features: 3D ready, 17,000:1 CR, 10,000
hours lamp life (ExtremeEco), 2 watt speaker, VGA x 2, VGA out x1
Native resolution: WXGA (1280×800)
Brightness: 3200AL
Key features: 3D ready, weighs 2.65kg, USB
display, wireless display (optional), power supply: AC100 to 240V, 50 to 60Hz
Acer: X1273N
BenQ: MW665
The author is a part of the editorial team at EFY.
By: Manvi Saxena
Epson:
EB-1420WI/1430WI
Native resolution: WXGA (1280×800)
Brightness: 3,300lm / 1,900lm
Key features: Weighs 5.6kg, 365W/274W
lamp, lamp type: 245W UHE
Some of the best projectors available in the Indian market
Native resolution: 1080p (1920 x 1080)
Brightness: 3000 ANSI lumens
Key features: 3D ready, weighs 2.2 kg, power supply:
AC100-120V (50/60Hz), wireless display (optional)
Hitachi: CP-DH300
Trang 20For the past few months, we have been discussing
information retrieval and natural language processing as well as the algorithms associated with them In this month’s column, we take a break
from our discussion of NLP and, instead, focus on
mobile application development We discuss some
of the recent research work on the energy consumed
by mobile apps Then we move on to mobile app
development, which has been growing at a furious
pace over the past few years and has attracted many
non-software developers to its fold, including school
students Learning to develop mobile apps using
open source software is quite easy In this month’s
column, we have one of our student readers, Ankith
Subramanya, who is a Class XI student from The
International School, Bengaluru, share his experience
of learning to develop an Android app
Energy consumption in mobile apps
Smartphones run complete operating systems tailored
for the mobile device, and support a wide variety of
additional hardware devices such as cameras, GPS, a
light sensor, accelerometer, gyroscope, compass, etc
Along with such a rich plethora of ‘exotic’ hardware,
smartphones also need to be extremely lightweight
and portable This requires that smartphone batteries
must be small and lightweight This, in turn, implies
that energy consumption in smartphones needs to be as
low as possible to conserve battery life Hence, energy
consumption by mobile apps needs to be tracked and
managed to extend the battery life of smartphones
Smartphones have become open platforms for
hosting a variety of applications Given the rapid pace
of mobile app development, more and more apps are
being developed, downloaded and installed on to the
device, without their performance, security and energy
characteristics being validated and documented This can lead to poorly written apps causing an abnormal drain on the device’s battery
Given a smartphone with a fully charged battery, the user expects that the device should be usable for
a certain number of hours without requiring a battery recharge The user is aware that prolonged use of certain hardware such as the camera, GPS, etc, can shorten the period before the next recharge However,
in the course of using normal apps, such ‘Abnormal Battery Drain’ (ABD) issues are not expected to occur When an ABD issue occurs, it is difficult for normal users to figure out what it is caused by
Some of the potential causes could be configuration changes; a hardware or software malfunction which keeps a power-hungry hardware component such
as the camera always on, even when not in use;
an app upgrade, etc Hence, intelligent tools are needed to diagnose ABD issues One such tool is a research project called eDoctor, which is described
in the following research paper http://cseweb.ucsd.
edu/~voelker/pubs/edoctor-nsdi13.pdf eDoctor
records various events such as configuration changes, app installations and app upgrades; and it monitors app phases Using this information, it tries to pinpoint what is responsible for the ABD
Given the importance of conserving battery life, smartphone OSs are designed to turn off hardware components the moment they detect that they are not
in use Smartphones employ aggressive CPU/screen sleeping policies Such measures can result in issues for apps which are in the middle of communicating with an external server and are waiting for data to be returned from the server In such cases, the device should not be put to sleep Hence, smartphone OSs export explicit ‘wakelock’ APIs, which can be used
In this month’s column, we shift our focus to mobile application development and
discuss the issue of energy consumption of mobile apps We also briefly cover
how a layman can quickly learn to develop Android apps.
Trang 21sleep However, bugs in mobile apps can cause ‘wakelocks’
to be misused, resulting in the device continuing to drain energy even when not in use For instance, if an application has acquired a ‘wakelock’ at some point in time, it should release the ‘wakelock’ to allow the device to go back to sleep
Failure to release the ‘wakelock’ can cause continuous drain
of the battery There has been considerable research work on detecting ‘wakelock’ bugs, also known as ‘no-sleep’ bugs A detailed discussion of ‘wakelock’ bugs can be found in the
paper http://web1.cs.columbia.edu/~junfeng/reliable-software/
papers/no-sleep.pdf.
While the previous research papers we have discussed focus on detecting energy bugs in smartphones by analysing the individual device’s behaviour, detecting energy
consumption anomalies by analysing the behaviour in individual phones is difficult since the energy consumption can vary widely due to different device configurations, different apps co-running simultaneously, and usage under different environmental conditions A novel direction in pinpointing energy bugs and high energy consumptions has been proposed in the free mobile app, ‘Carat’, which is
available from http://carat.cs.berkeley.edu/
Carat uses a collaborative approach to detect anomalies by collecting energy information from a wide variety of devices and uses that information to detect anomalous behaviour on
an individual smartphone Each smartphone on which Carat
configuration settings, the set of applications installed and set
of apps running currently to a centralised server Data from
a wide number of devices is collected, stored and analysed
in the centralised database, to infer statistically, a normal energy consumption pattern for a device If the measurements reported from the device deviate considerably from the expected consumption, an energy consumption anomaly is flagged by the app
While the tools we have discussed so far help to detect abnormal energy consumption by applications in smartphones,
as an app developer, you would be interested in making sure that your app is ‘well-behaved’ with respect to energy consumption The open source tool JouleUnit is an energy
profiling and testing framework, and is available at https:// code.google.com/p/jouleunit/ The JouleUnit workbench is
integrated into the Eclipse IDE, and allows you to construct and trigger energy tests for your app from the Eclipse IDE
Learning to develop Android apps
One of our student readers, Ankith Subramanya, had written to
me, sharing his experience on how he rapidly learnt Android app development Given the enormous interest in mobile app development even from non-core programmers, I felt that it would be useful to share his experience in this column, for the benefit of those who are interested in learning Android app development Here are Ankith’s comments:
You can mail us at osfyedit@efy.in You can send this form to
‘The Editor’, OSFY, D-87/1, Okhla Industrial Area, Phase-1, New Delhi-20 Phone No 011-26810601/02/03, Fax: 011-26817563
None
OSFY?
Customer Feedback Form
Open Source For You
Trang 22“I’m writing this for those novices out there who are itching
to develop Android apps, but don’t yet know how to Until a
few weeks ago, I too had no idea about creating Android apps,
but I really wanted to develop my own mobile apps I did some
reading on the Internet, and found out that Android apps are
developed using Java I was a little disheartened at first because
I had never learnt Java or, for that matter, any Object Oriented
Programming language Nonetheless, I found the time in my
summer vacation to attend a few classes on Java at a local
teaching centre A few weeks into it, I discovered that Java is
extremely intuitive and easy to grasp
“Earlier experience in Java would definitely be a plus
point, but don’t be disheartened if you don’t know any Java
at all There are plenty of resources online to help you learn,
and using a book wouldn’t be a bad idea as well I must stress
that getting your syntax bang on is not as important as getting
the hang of the basics and the fundamental concepts You
should have a solid understanding of OO concepts such as
object creation, inheritance, overriding, interfaces, collections,
packages, etc These might sound like Greek and Latin, but
once you get started on Java, this will be your bread and
butter
“A lot of people think that knowing XML is crucial in
building Android apps, but the truth is that you can build
whatever you want with no previous knowledge of XML
This is basically because the XML elements are integrated
as a drag and drop feature in the Android environment Also,
XML is very simple and you will definitely pick it up while
building an app Learning Android is merely about getting
to know a few additional concepts First, visit developer.
android.com You will find instructions there to install and
set up your SDK (what you’ll need to develop the apps)
This contains half-built Android programs, in the sense that
it contains incomplete classes that you have merely to extend
(again, don’t worry about these terms, you’ll understand them
soon enough) to build your apps This way, it becomes very
simple as you don’t have to start from scratch
“There are plenty of resources online to help you learn
Android Udacity (www.udacity.org) and Coursera (www.
coursera.org) offer courses on mobile app development
The course in Udacity, named ‘Developing Android apps’,
is interactive and is centred on the purpose of making you
build your own weather app The entire course involves
the steps to build that app, and you are expected to do so
on your own The idea is that, from this, you will develop
your skillsets to develop your own Android apps This
is a very nice concept, and provides a hands-on learning
experience There is also another course available from
Coursera titled, ‘Creative, Serious and Playful Science of
Android Apps’ This requires no previous knowledge of
Java You may find this useful as well
“The two IDEs that you can use for Android
development are Android Studio and Eclipse While both
are very similar in many ways, I use Eclipse, though this
is entirely your choice As Android Studio is still in the early stages of development, and as only the beta version
is available for use, I would recommend using Eclipse (www.eclipse.org) Android apps can be made on Eclipse
by downloading the necessary plugins The complete package that you need to install, including Eclipse with the necessary plugins, as well as the SDK manager (an app that manages the downloading and installation of build
tools and libraries) is available on developer.android.com,
and is called the ADT (Android Developer Tools) bundle (JDK must be pre-installed) The IDE contains Java classes and XML files, that are made to interact with the help of Android manifest, which is an XML file
“Essentially, each screen of an Android project is called
an activity, and every activity has a backing XML file and Java class Android apps follow the MVC (model view controller) design pattern The XML file, which is for UI, acts as the view, whereas the backing Java classes are for the model and controller If you do not wish to do the XML part, the UI can be designed by the intuitive dragging and dropping
of UI elements (called views), and the IDE will automatically make changes in the XML file
“Debugging is made simple with the help of LogCat,
a debugging tool that shows what exactly is going on at every step in the runtime of the application The app that you create can be run either using an emulator or on your Android device I would recommend the latter, as the emulator is incredibly slow in loading If you want to run on your Android device, make sure that you install the device driver Also, if your Android version is 4.2 or higher, you will need to turn on developer options You can do this by going
to ‘About phone’ in ‘Settings’ and then clicking on ‘Build version’ However, if you do not have an Android device, you will have to create an emulator on AVD (Android Virtual Device) manager Simple apps such as a calculator and apps
to print out your name are surprisingly easy to build Now go, get started on your Android adventure!”
Thank you, Ankith, for sharing your experience on learning Android app development!
If you have any favourite programming questions/software topics that you would like to discuss on this forum, please send them to me, along with your solutions and feedback, at
sandyasm_AT_yahoo_DOT_com Till we meet again next
month, happy programming!
The author is an expert in systems software and is currently working with Hewlett Packard India Ltd Her interests include compilers, multi-core and storage systems If you are preparing for systems software interviews, you may find it useful to visit Sandya’s LinkedIn
group: Computer Science Interview Training India at http://www.
Trang 24Hadoop is a large scale open source storage and processing framework for data sets This article builds upon the previous article in this series, ‘Exploring Big Data on a Desktop: Getting Started with Hadoop’ that appeared in last month’s issue of OSFY
The focus, now, is on putting data into the system
Exploring Big Data on a Desktop
Putting Data into HDFS
Once you have the basics of Hadoop functioning, the
obvious question is: how does one put the data into
the system? And the corollary to that is: how does
one distribute the data between the various data nodes? Since
the system can grow to thousands of data nodes, it is pretty
obvious that you should not have to tell HDFS anything more
than the bare minimum
A simple test
Your first test can be to take a large text file and load it into
HDFS Start the Hadoop cluster as described in the previous
article, with three nodes On the first test, stop the datanode
service on h-mstr and copy a large file on two slave nodes
(To create a text file for testing, take a hexdump of a 1GB tar
—you should get a text file of around 3GB.)
$ ssh fedora@h-mstr
$ sudo systemctl stop hadoop-datanode
$ hdfs dfs -copyFromLocal large_file.txt
You can verify that the data has been copied and how
much resides on each node, as follows:
The data file is distributed on h-slv1 and h-slv2 Now, start
the datanode on h-mstr as well Run the above commands
again, as follows:
$ sudo systemctl start hadoop-datanode
$ hdfs dfs -copyFromLocal large_file.txt second_large_file.txt
$ hadoop fs -ls -h -rw-r r 1 fedora supergroup 3.3 G 2014-08-15 12:25 large_file.txt
-rw-r r 1 fedora supergroup 3.3 G 2014-08-15 12:33 second_large_file.txt
and store the data close to the origin You can find out about the status of HDFS, including the location of data blocks, by
browsing http://h-mstr:50070/
The file you want to put in HDFS may be on the desktop You
can, of course, access that file using nfs However, if you have
installed the HDFS binaries on your desktop, you can copy the file
by running the following command on the desktop:
$ HADOOP_USER_NAME=fedora hdfs dfs -fs hdfs://h-mstr/ -put desktop_file.txt
The commands -put and -copyFromLocal are synonyms.
Replication
You should stop the Hadoop services on all the nodes In /etc/
hadoop/hdfs-site.xml, on each of the nodes, change the value of dfs.replication from 1 to 2 and the data blocks will be replicated
on one additional datanode
<property>
Anil Seth
Trang 25<name>dfs.replication</name>
<value>2</value>
</property>
Restart the Hadoop services Increase the replication for
existing files and explore http://h-mstr:50070/
$ hadoop fs -setrep -R 2 /user/fedora/
These experiments illustrate the resilience and flexibility
of the Hadoop distributed file system, and the implicit optimisation to minimise the transfer of data across the network You don't need to worry about distribution of data
During your experiments, in case you come across the
error stating that the namenode is in safe mode, run the
following command:
$ sudo runuser hdfs -s /bin/bash /bin/bash -c "hdfs dfsadmin -safemode leave"
Loading data programmatically
It is likely that you will need to get the data from some existing sources like files and databases and put what you need into HDFS
As the next experiment, you can take up the document files you may have collected over the years Convert each into text and load them Hadoop works best with large files and not with a collection
of small files So, all files will go into a single HDFS file, where each file will be a single record with the name of the file as the prefix You don't need to create a local file The output of the
program can be piped to the hdfs dfs -put command.
The following Python program load_doc_files.py
illustrates the idea
It selects document files
Each document file is converted to a text file
The name of the file is output with a delimiter (a tab, in this case)
Each line from the file is read and output with the new line character replaced by a delimiter
On reaching the end of the file, a new line character is written to the standard output
#!/usr/bin/python from future import print_function import sys
import os import subprocess DELIM='\t' FILETYPES=['odt','doc','sxw','abw']
# use soffice to convert a document to text file def convert_to_text(inpath,infile):
to','txt:Text',
' outdir','/tmp','/'.join([inpath,infile])]) return '/tmp/' + infile.rsplit('.',1)[0] + '.txt'
# Convert & print file as a single line replacing '\n' by '\t' adding file name at the start
def process_file(p,f):
print("%s"%f, end=DELIM) textfile = convert_to_text(p,f) for line in open(textfile):
print("%s"%line.strip(),end=DELIM) print()
# Generator for files of type odt, doc, etc.
You may run the above program as follows, from the desktop:
$ /load_doc_files.py ~/Documents | HADOOP_USER_NAME=fedora \ hdfs dfs -fs hdfs://h-mstr/ -put – doc_files.txt
The above program can be easily extended to convert and load PDF files as well Or another program can be used to append to the existing HDFS file
The obvious next step is that once the data is in Hadoop, you need to figure out how to use it and what you can do with it
An example of modified word count
Hadoop Map-Reduce offers a very convenient streaming framework It takes input lines from an HDFS file and passes them on standard input to one or more mapper programs The standard output of the mapper programs is routed to the standard input of the reducer programs The mapper and reducer programs could be in any language
Each line of a mapper output is expected to be a keyword, value pair separated by a tab All lines with the same keyword are routed to the same reducer
A common first example is a word count in a text file Each line of a text file is split into words by a mapper It writes the word as the key with the value 1 The reducer counts the number of times a particular word is received Since the word is the key, all occurrences of the same word will be routed to the same reducer
In doc_files.txt, each line is actually a file It is very likely
that words will be repeated in a line So, it is better if the
mapper counts the words in a line before writing to stdout, as
Trang 26shown in the following mapper.py:
# count the number of occurences of a case-insensitive word
for word in words:
if word != '':
wd = word.lower()
wd_dict[wd] = wd_dict.get(wd,0) + 1
# print each word and its count
for word in wd_dict:
print('%s%s%d'%(word,sep,wd_dict[word]))
if name == " main " :
main()
There is no need to change the reducer function as long
as it had not assumed that the count of each word was 1 The
corresponding reducer.py:
#!/usr/bin/python
import sys
# convert each line into a word and its count
The author has earned the right to do what interests him
You can find him online at http://sethanil.com, http://sethanil.
blogspot.com, and reach him via email at anil@sethanil.com
By: Dr Anil Seth
def read_mapper_output(file, sep):
for line in file:
yield line.strip().split(sep)
# add the count for each occurrence of the word def main(sep='\t'):
wc = {}
for word, count in read_mapper_output(sys.stdin, sep):
wc[word] = wc.get(word,0) + int(count)
# print the sorted list for word in sorted(wc):
print("%s%s%d"%(word,sep,wc[word]))
if name == " main ":
main()
So, having signed into fedora@h-mstr, you may run these
commands to count the words and examine the result:
$ hadoop jar /usr/share/java/hadoop/hadoop-streaming.jar \ -files mapper.py,reducer.py -mapper mapper.py -reducer reducer.py\
-input document_files.txt -output wordcount.out
$ hadoop fs -cat wordcount.out/part-00000 | less
As seen in the earlier experiments, you can store the data
in a HDFS file using any programming language Then, you can write fairly simple ‘map and reduce’ programs in any programming language, without worrying about any issues related to distributed processing Hadoop will make the effort
to optimise the distribution of the data across the nodes as well
as feed the data to the appropriate mapper programs
July 2014 Firewall and Network security Web Hosting Solutions Providers MFD Printers for SMEs
August 2014 Kernel Development Big Data Solutions Providers SSDs for Servers
October 2014 Mobile App Development Training on Programming Languages Projectors
November 2014 Cloud Special Virtualisation Solutions Providers Network Switches and Routers
January 2015 Programming Languages IT Consultancy Service Providers Laser Printers for SMEs
February 2015 Top 10 of Everything on Open Source Storage Solutions Providers Wireless Routers
osFy Magazine attractions during 2014-15
Trang 27This article will interest programmers and engineering students It describes various open source tools that C programmers ought to add to their toolkit.
many people still cling to this tool, citing ease of use I have had
a difficult time convincing others how easy it is to use the Linux environment to program in C, and this article has its roots in my frustration over this argument In this article, I have presented a few open source tools that will make the life of a C programmer comfortable in the Linux environment
There are lots of open source tools that can be used to automate and simplify many of the steps involved in program development, using C This list is in no way comprehensive, but the tools have been selected based on my experience and personal preferences So the relevance of a particular tool might be debatable, occasionally, but the general idea is
to introduce some useful tools to the interested user Open source tools from the following categories will be discussed:
• Integrated Development Environments
• Build automation tools
• Revision control systems
Open Source Tools That Simplify
Tasks for C Programmers
Even though C was developed around 1973, it still elicits
a fair share of interest from professional programmers
But beyond this, C is also the preferred language of academia There is possibly not a single university in the world which does not have a C programming paper in its undergraduate curriculum The destinies of C and UNIX have been intertwined ever since they were created C is most powerful when it is used with UNIX In fact, the system calls and commands of UNIX/Linux invigorate C programs
Unfortunately, in India, this language is most often taught using proprietary tools To add insult to injury, the most widely used IDE is Turbo C++ for Microsoft Windows, a product of Borland Software Corporation, an erstwhile software company The last stable version of this IDE was released in 1996, which makes it
as old as many of the first-year undergraduate students who use
it In 2006, the Turbo C++ IDE was released as freeware, which effectively tells us that the software has become obsolete But
Trang 28• Debuggers
• Code coverage tools
• Static code checking tools
• Dynamic code checking tools
• Profiling tools
• Code formatters
• Documentation generators
• Open source libraries
Integrated Development Environments
An Integrated Development Environment (IDE) is an application
that provides comprehensive facilities for software development
There are a large number of IDEs available for C programmers
Some of the popular open source IDEs include Code::Blocks,
CodeLite, Geany, etc In this race, Code::Blocks is the clear
winner because of its ability to perform debugging, profiling,
code completion, code coverage testing and static code analysis
Moreover, if you are an expert user of Code::Blocks, there won’t
be many practical situations for which you will need another
tool for program analysis Code::Blocks is a cross-platform
application that will work on Windows, Linux and Mac OS X
The different compilers supported include GCC, MinGW, Digital
Mars, Microsoft Visual C++, Borland C++, LLVM Clang, etc
The latest stable version is Code::Blocks 13.12, which was
released on December 27, 2013
Build automation tools
Build automation is the process of automating tasks like
compiling source code to binary code, running tests and
deploying the final application Here too, we have a wide variety
of tools to select from Some of the popular tools include Make,
Waf, and Automake Waf is a Python-based tool which is gaining
popularity But Make is still the preferred tool for C developers
C program compilation can be automated with the Make utility
by executing the command make This will execute the Makefile,
which should contain all the rules to automatically compile and
build an executable from the source code The rules mention
prerequisite files and actions to be carried out in order to obtain a
target file You can download the source code of the C program
and a Makefile from http://opensourceforu.com/article_source_
code/sept14/make.zip The zip file contains two C program files
main.c and fun.c, a Makefile to build the source files and an
image showing the output of Make
There is some criticism about the Make utility regarding
the rigid structure and syntax of the Makefile Some criticism is
based on the fact that Make offers too little in comparison with
other tools like Waf But, personally, I believe the best feature
of Make is its simplicity and the criticism arises from the fact
that it has been in use for the past 30 years As often quoted,
familiarity breeds contempt and with that, I rest my case
Another tool which is often mentioned in conjunction
with build automation is Automake, which is part of the GNU
toolchain Automake is an autotool used to automatically
generate Makefiles for the Make utility
Revision control systems
Another important tool that should be in the arsenal of a C programmer is a revision control system, a.k.a a version control system A revision control system is used when the changes made to the software being developed are very high, which makes it difficult to version properly Here too,
we have to choose from a wide list of tools, which include Mercurial, RCS, CVS, etc Among all the different tools available, Mercurial is very simple and efficient
The command hg init is used to initialise the repository by creating a directory called hg The hg status command tells
us the status of the files being tracked by the repository hg add file_name is used to add files for tracking You can use the command hg commit to save different versions of your program files hg log gives the details of different versions
being tracked by the repository And to revert to older
versions, use hg revert –ar version_number.
One common error message that haunts first time users of
Mercurial is ‘abort: no username supplied (see «hg help config»)’
If you get this error, you should edit the file hgrc located inside
your home directory and add the following lines of text:
[ui]
username = Your Name <your@email.com>
Debuggers
For novices, writing a program devoid of syntax errors is
a difficult task But the real difficulty occurs while dealing with run time errors As the size of the program increases, identifying bugs that cause run time errors becomes more and more difficult In order to debug large programs, we ought
to get help from debuggers like GDB, DBX, DDD, etc The debugger GDB (GNU Debugger) has become so popular and influential that the selection of a debugger is made very easy for most of the programmers In fact, most other debuggers are influenced by GDB, with DBX being the only real competitor that is not based on the philosophy of GDB The success of GDB even led to the development of a GUI-based debugger called DDD (Data Display Debugger) based on GDB
GDB allows you to inspect various program parameters during and after program execution Errors like segmentation faults are identified with relative ease using GDB The C program fragment given below contains a run time error and GDB is used to uncover it
int a=111,b=0,div;
div=a/b;
printf(“After division result is %d\n”,div);
The program compiles without any syntax errors but contains a logical error The program should be compiled as
follows to enable debugging with GDB: gcc -g program_
name.c The option -g enables built-in debugging support
required by GDB You can start the GDB debugger by using
Trang 29the gdb command The transcript below shows the GDB session, which debugs the program gdb_example.c.
(gdb) file /a.out Reading symbols from /root/Desktop/gdb/a.out done.
(gdb) run Starting program: /root/Desktop/gdb/a.out Program received signal SIGFPE, Arithmetic exception.
0x08048422 in main () at gdb_example.c:8
8 div=a/b;
The message clearly tells us that the run time error is due to
division by zero The command file is used to open an executable file for processing by GDB The run command runs the program
completely if there are no errors and stops processing with a diagnostic message at the first instance of a run time error A very rich command set is available for fine tuned debugging of buggy programs and this makes GDB a tool of great importance
Code coverage tools
Source code coverage analysis tools tell the programmer the number of times each instruction in a program is executed This information can be further used by the programmer to remove dead code and optimise the frequently executed instructions
in a program GCC offers a very simple and elegant tool for code coverage analysis called Gcov The program should be compiled as follows to enable the proper working of Gcov:
gcc -Wall -fprofile-arcs -ftest-coverage program_name.c The
option -Wall shows all the warnings, the option -fprofile-arcs is
to deal with the execution of branch statements and the option
-ftest-coverage adds the number of times each line is executed
After compilation, the program should be executed once before calling the Gcov utility The following command calls the Gcov
utility: gcov program_name.c This will create a file called program_name.c.gcov which contains the output of Gcov This
file contains the program annotated with the line number and the number of times each line is being executed Dead code that
never gets executed is marked with the symbol ‘#####’ Figure 1 shows the output of Gcov for a program called gcov_example.c.
Static code checking tools
Static code checkers uncover security vulnerabilities and coding mistakes Static code checking is carried out by analysing the source code or the object code In static code checking the executable code is never analysed The standard static code checking utility of Linux was Lint But nowadays, the most popular static code checker for the Linux environment
is Splint (Secure Programming Lint) Splint can uncover unused declarations, the use of variables before definition, type inconsistencies, unreachable code, ignored return values, infinite
loops, etc Consider the program buggy_program1.c for a
demonstration of Splint’s ability to uncover potential errors
#include<studio.h>
int main() {
The program can be processed with Splint by using the
following command, splint program_name.c This will list many
unwanted warnings about potential threats which do not hinder program processing These warnings can be suppressed by turning
on the flag weak, as follows, splint -weak program_name.c The three potential logical errors in the program buggy_ program1.c are uncovered by Splint after analysing the source
code The three potential problems are the use of variable ‘i’ before initialisation, the assignment of a character value to the integer variable ‘i’ and the use of the undefined expression
++i+i++ This shows us that Splint can uncover many
potential threats unidentified by the compiler
Dynamic code checking tools
Dynamic code checking involves the analysis of the executable file and system execution of a program to identify potential threats Let’s discuss a dynamic testing tool called Valgrind, which is used for memory debugging and memory leak detection Sometimes Figure 1: Output of Gcov
Trang 30even the most advanced programmers commit memory related
errors This makes Valgrind a tool that’s sought after even by the
most seasoned programmer The working of Valgrind is explained
with the help of the program buggy_program2.c given below
/* Program name : buggy_program2.c */
This program is compiled to get the executable by typing the
command gcc program_name.c The executable created is used by
the Valgrind utility to identify memory related vulnerabilities There
are multiple tools in Valgrind The default and most frequently used
one is Memcheck The command for invoking Valgrind is valgrind
executable_name Valgrind will identify both the memory related
errors in the program, the invalid write at location ptr[5] and the
memory leakage of 5 bytes caused by not calling free( ).
Profiling tools
Profiling tools are used to analyse the performance of a program
They are used to analyse both the space and time complexity of
a program They also carry out a form of dynamic code analysis
The most widely used performance analysis tool for C is Grprof,
an extended version of an older tool called prof Profiling should
be enabled while compiling the programs as follows A program
called gprof_example.c is used to analyse how Gprof works.
/* Program name : gprof_example.c */
The Gprof utility should be enabled while compiling the
program as follows: gcc -p program_name.c Before calling
Gprof, the program should be executed once This will create
a file called gmon.out This, along with the executable file,
is used by the Gprof utility to analyse the performance of
the program The command to call Gprof is: gprof a.out gmon.out The time taken by various functions can be easily understood from the output of Gprof If the program gprof_
example.c is processed with Gprof, then you will observe that the execution time for function delay2( ) is roughly 10 times that of function delay1( ) This sort of information can be
further used to identify functions that require optimisation
Code formatters
There are programming languages like Python and Occam in which the formatting style of the program is as important as the syntax to get the correct output Such languages force the programmer to write well intended programs But C is a free-form language, which does require proper formatting to obtain the correct output The result of such freedom, if misused, often gives nightmares and sleepless nights to many a programmer
It is very difficult to debug programs if the code is not properly intended Many different styles have been proposed for formatting
C programs Some of the very popular ones are K&R style, GNU style, Kernel style, etc Problems arise when programmers with different formatting styles work together on a project This problem can easily be solved by using a code formatter, which can translate code from one style to another The most widely used code formatter in the Linux environment is Astyle It supports multiple styles like Allmann, KR, GNU, etc, which are suitable Figure 2: Beautifying programs with Astyle
Trang 31for formatting C programs Astyle also has other options to set parameters like the bracket style, tab size, indentation style, empty
line padding, etc Figure 2 shows a program called astyle_example.c
formatted in a style that ought to be called ‘chaos’ If the program was a bit lengthier, it would have been impossible to fathom and any decent programmer would curse me for my insolence But the figure also displays the magic of Astyle by changing the format
of the program to GNU style Yes, the ugly duckling has finally become a swan The original unformatted program is stored in a file
called astyle_example.c.orig.
Document generators
While writing efficient programs involves logical reasoning and is hence a task for the left hemisphere of the human brain, preparing documentation involves creativity and is handled by the right hemisphere of the brain No computer in the world can perform creative writing, but automatic document preparation from specially commented programs has become a reality
Document generators are able to produce API documentation for programmers and user manuals for end users Doxygen is one of the most widely used document generators and one that is highly suitable for the C language It can cross-reference documentation and code, and the documentation part is written within the code
The program fragment shown below contains Doxygen based comments The comments are ignored by the C compiler but they are recognised and processed by Doxygen
Doxygen can be called as follows to process the C file:
doxygen program_name.c It can prepare documents in the form
of HTML, XML, RTF, etc Doxygen can also produce a Latex file as output, which can be further processed to obtain output
in the PDF or DVI format The example program given above uses only the basic tags There is a large set of tags available to prepare all kinds of documentation
Open source libraries
One severe criticism that C has faced over the years is with respect to the scarcity of useful library functions To some extent, this is true, because when compared with languages like Java or Python, the number of library functions is comparatively less But to overcome this drawback and to aid
us in development, there are countless open source libraries that can be used along with the C standard library The open source libraries range from the ones which allow us to draw images, to the ones which add security to our systems
Some of the open source libraries widely used along with the C language include OpenGL, OpenCV, OpenSSL,
etc OpenGL is a cross language application programming interface to handle 2D and 3D vector graphics It is used in CAD, flight simulation, scientific visualisation, etc OpenCV
is a library of functions that can be used for applications related to computer vision Even though the latest interface
is based on C++, OpenCV still maintains an older C-based interface OpenSSL is an implementation of SSL and TLS It contains a lot of cryptographic functions to be used in security related applications And remember, this is just the tip of the iceberg; there are hundreds of useful open source libraries
A thorough discussion of all the tools and packages described in this article will take up scores of text books I hope this introduction will help you start a lifelong journey on interacting with the elegant language called C The best thing about the tools discussed here is that they are all open source technologies Hence, there are countless manuals freely available on the Internet Go through the manuals and learn these tools; you can use them with many other languages and platforms because most of them are not limited to C
By: Deepu Benson
The author has nearly 15 years of programming experience and
is working as an assistant professor in Amal Jyothi College of Engineering, Kanjirappally, Kerala He maintains a technical blog
at www.computingforbeginners.blogspot.in and can be reached
at deepumb@hotmail.com.
EMBEDDED SOFTWARE
DEVELOPMENT
COURSES AND WORKSHOPS
Porting an Embedded RTOS - Driver Development and Board Support
FACULTY : Babu Krishnamurthy
(Visiting Faculty, CDAC/ACTS - with 18 years of Industry and Faculty Experience)
AUDIENCE : BE/BTECH Students, PG Diploma Students,
ME/MTECH Students and Embedded / sw Engineers
DATES : October 11 and 12 ( 2 days program )
NOMINAL FEES : Rs 6742.00 (inclusive of taxes) per delegate
VENUE: School of Embedded Software Development,
M.V Creators' Wing, 3rd Floor, #218, Sunshine Complex, Kammanahalli, 4th Main, 2nd Block, HRBR Layout, Kalyan Nagar, Bangalore - 560043.
(Opposite to HDFC Bank, Next to FoodWorld and near JalaVayu Vihar )
Email : babu_krishnamurthy@yahoo.com
Phone : 080-41207855
SMS : +91-9845365845 ( leave a message and we will call you back )
UPCOMING COURSES : Linux Device Drivers - Architecture, Internals and Programming Dates - November 14, 15 and 16 ( 3 days program )
Trang 32This article presents Tornado, the Python Web framework Originally developed at FriendFeed,
Tornado is an asynchronous networking library It is able to scale up to tens of thousands of
open connections with the help of its non-blocking network I/O.
Tornado: A Python Web Framework
That’s Simple and Quick
is Facebook’s real time Python Web framework (we will go into this later) It enables a clean approach to Web server programming, focuses on non-blocking operations and scales
to an enormous number of open connections Tornado is an asynchronous networking library that was originally developed
at FriendFeed, a kind of social network that enables you to share the issues you found on the Web and it allows discussions
FriendFeed was acquired by Facebook in 2009 and Tornado was open sourced soon after Django, CherryPy, web2Py, Grok, Pylons and TurboGears are some of the other frameworks
Why Tornado?
So why is Tornado preferred, even though Python has a number of frameworks? Well, Tornado is noted for its high performance and supposedly has the capacity to solve the C10k problem (problem of optimising network related issues
so that it can handle a large number of clients at the same time) that affects other servers Tornado focuses on speed and handling large volumes of simultaneous traffic
Let’s look at those features of Tornado that differentiate it from other frameworks
Built-in support: Tornado comes with built-in support
and finds solutions for most of the tedious aspects of Web development like templates, localisation, signed cookies, etc
Tornado also allows users to mix it with other frameworks,
Apart from introducing you to Tornado, this article
explores the extent to which it can be scaled, its
features, the installation process, and its advantages
compared to other Python Web frameworks This article
is meant for those interested in knowing more about Web
designing as well as Web developers It may even be helpful
to serious Python developers or contributors trying to explore
ways to improve their Web development skills
A framework is a collection of programs that uses
a control mechanism to structure code to build a bigger
system We can develop simple websites using basic
designing languages like HTML, CSS, Python, etc However,
considering the complex and dynamic nature of the Web, it is
difficult to do this at a low cost and within the short deadlines
that sites are typically developed Hence, developers want
something that empowers them and has fewer bugs The
purpose of a Web framework is to provide some features that
are essential for all kinds of applications, such as database
support, URL handling, HTML templating, etc
Python is one of the most used general-purpose
programming languages It is also used as a scripting language
but mostly in non-scripting contexts Python’s environment
consists of a number of Web frameworks, ranging from the
minimalistic to the fully bloated Tornado is one of the best
Web frameworks of the Python programming language It
Trang 33with matching snippets, according to their needs.
Concurrent connections: Tornado offers real time services
and supports a large number of concurrent connections, HTTP streaming (a communication protocol implemented by Apple Inc) and long polling (it is a ‘push’ technology, which allows
an emulative push mechanism under circumstances in which a real push is not possible) With Tornado, it is very easy to write real time services FriendFeed maintains an open connection, especially for its frequently involved users
High performance: This is Tornado’s most attractive
feature It is very fast compared to all other Python Web frameworks Considering its baseline output, it is around four times higher in speed and pretty efficient also
Getting started with Tornado
Tornado platforms: Tornado runs on most of the platforms
like UNIX, Windows, and so on For better performance and scalability, only Linux with EPoll (a Linux kernel system call which replaced older calls to achieve better performance), and BSD (Berkeley Standard Distribution) with KQueue (an event-notification interface) are recommended for effective production deployment Windows is officially not supported but is recommended only for development purposes
Installation: Tornado is listed in PyPI, which is a Python
Package Index—a repository of software for the Python programming language As Tornado is listed in PyPI, it can be installed easily using Pip:
pip install tornado
As an example, let’s create a new project called
webappdemo We have the app.py python file whose contents
are as follows:
_app_: It is the main method for Python to start executing
and is the entry for the program
tornado.ioloop: The ioloop class is the main event for
any application which can create a non-blocking thread for an application
tornado.web: This is the basic module of Tornado, which
implements a lightweight Web development framework It was built in FriendFeed using their non-blocking HTTP server and low-level I/O modules In this demo, MainHandler is the single handler mapped to the root path
MainHandler: This is a handler for a request, which refers
to the self.write() method The MainHandler class returns the
response using this method
application listen (8888): We look at the specification 8888
first It is just a port which the application considers (i.e., listens to) Any one can communicate with this application through this particular port (8888)
It’s now time to run the application You can run this simple application in a terminal (if you are using Ubuntu) If you are using the Windows platforms, you can run this application using the command prompt
Figure 1: Python frameworks
To run your application in a terminal, use:
python app.py
Finally, you should be able to visit your website at http:// localhost:8888
Tornado and other Python Web frameworks
Pyramid, Flask, Bottle and Django are among the well known frameworks of Python
Pyramid is a small framework which makes real-world
Web applications productive Its advantages over other frameworks are:
A quick start
Flexibility
Compatible with Python 3
Ability to develop large Web applications, etc
Flask is a micro framework of Python which is easy to set
up and comes with a built-in server Flask’s main features are:
It implements most commonly used core components
Provides users a choice for database access or validation
Flask extensions are available
Bottle is a framework that provides minimal tools
out-of-the-box (routing, templating, etc)
It also comes under the category of ‘micro’ , which enables
compilation in Python 3 Some of the other features of Bottle are:
Ability to build simple projects
Efficient in creating Web application interfaces
Flexibility
Django is a powerful Web framework that is supported
by a large and active community It offers model-based forms and has its own excellent documentation Django makes it easier to build better Web applications, quickly and with less code It is a high-level Python Web framework that encourages rapid development and perfect design
Some of the attractive features of Django are:
Predefined powerful admin interface
Offers model-based forms
Django extensions are available
Has useful applicationsThe purpose of a Web framework is to provide some common features that are essential for all kinds of
Python
Django Flask Bottle
Trang 34its template system efficiently.
The template system syntax of Tornado is a lot like Django’s and almost interchangeable: you get template inheritance, variable binding, looping and localisation support just as with Django
Yet, it executes a lot faster with less code under the hood You can also short-circuit template compilation for speed by carefully instrumenting which files you’ll include conditionally The template values are replaced in Django when you assign variables
to an HTML template This is also possible for the programs written outside of the Python code This is fairly standard practice these days and Django does a great job of it The template inheritance is a simple yet powerful way of defining standard headers and footers, as well as other features, so that they exist on every page The templating is not the fastest on the Web, however;
so you should plan for additional processing time
Since it is such a mature system, Django has all kinds
of other features as well: user authentication, localisation, Unicode handling, and the list goes on If you want a framework that will cover everything you can possibly need and you just don’t have the time or skill to do a lot of the work to get it done, then Django is a great system for you An interesting fact about it is the way it’s described—Django is the Web framework for perfectionists with deadlines
The real differentiating glory of Tornado is the IOLoop, an asynchronous software library that integrates directly with kernel EPoll, KQueue and similar facilities Also known as an Event Loop, this style of programming allows your program to detach its flow control, so the system can respond to another Web request while you wait for the kernel to dispatch your event Tornado gives you great access to the internals of the system to make it do exactly what you want The localisation and Unicode support is pretty thorough - you can create CSV key/value pair files, and look up the values based on the browser language headers As long as you design your system in an open manner, you can serve your whole website in multiple languages and ensure it executes faster
I do hope you’ve got a basic understanding of Python Web frameworks and familiarised yourself with Tornado Now it’s your turn to dive into the code and come up with amazing Web applications If you’re starting a new project, I highly recommend Python It’s a great language with enough clarity, speed and features for you to bring together a global team to build a high-performance website If you want to choose a Web framework that suits your team and project, the Python community members are there to help you out! They are really awesome!
applications The Model-View-Controller (or MVC) is software
for implementing user interfaces and is the de-facto standard
for developing Web applications Both Tornado and Django
provide some form of database support, HTML templating,
domain handling, etc
Tornado vs Django
Even though both Tornado and Django provide the MVC
architecture, they are at opposite ends of the spectrum
Django is more mature and is one among the largest
Web-based frameworks for Python It has a lot of features and
takes care of the details for the user, so that you do not need to
understand all the basics when making a fully-featured website
It is stable and user friendly too But Django is very hard to
customise and troubleshoot, in some situations, due to its
all-encompassing nature This is one of its drawbacks
Tornado is lighter in weight and has a few more features
than Django As I said earlier, Tornado is known for its high
performance It runs faster and provides an asynchronous
IOLoop for polling requests, and a variety of oauth and social
media features It is small in size and runs fast And it is
customisable to the tiniest detail
Django actually fits most of the platforms HTTP requests
are a fundamental part of every Web application This applies
to Django too Controllers of this framework allow regular
expression matching on URLs, to call the appropriate functions
and field incoming requests It assures sensible default requests
and responses, with the ability to override Tornado is the leanest
and meanest among the featured Python Web frameworks As I
mentioned before, Tornado is fast, and is small too—in the sense
that it is simple and yet efficient These features make access
points easy for extending the framework itself and directly
managing the basic expectations of a Model View Controller
framework It also manages the basic operations of your website,
such as parameter parsing, HTTP handing, etc URLs of both
Django and Tornado are almost similar The only difference is
that they use separate classes for each request This makes it
possible to create a class hierarchy for your requests, and then
you can paste together a series of pages into a single parent class
If you want to start a company or business that involves
collecting data from users and storing it in a database, Django will
really help you out It has a form generator, which will allow you
to define patterns for the database, and it also helps in generating
HTML for an application which validates data on submission The
sophisticated data model reads your existing database schema,
or creates one for you, and generates code to define the schema
as software objects In Tornado, the database connectivity is not
built in by default, but it does not exist in a separate package and
is known by the name torndb This database helps in connecting
to MySQL and issues your queries For example, if you want
to create your own environment for managing connections and
retrying failed queries, then this is the one place you make real use
of Tornado It will work exactly how you want it to
Django provides the ‘View’ part of MVC by making use of
[1] https://devcharm.com/articles/16/tornado-examples/
[2] http://carlosgabaldon.com [3] http://backchannel.org [4] https://wiki.python.org/moin/WebFrameworks
References
By: Anjana S
The author is an open source enthusiast She can be reached at
anjanasasindran123@gmail.com.
Trang 35Here’s an introduction to Flask Microframework, which can be used to easily build and deploy good Web applications with the minimum of effort and time Added security and functionality for the app is provided by the Jinja 2 engine.
entity tags, cache control headers, HTTP dates, cookie handling, file uploads and a powerful URL routing system It does not force you to use a specific template engine or any other extension, but leaves everything else to you, the developer, to choose
Jinja2
This template engine is mainly used for creating static or dynamic Web pages with minimal coding A basic layout can be set up and used for a large number of static or dynamic pages with little coding Flask uses the Jinja2 template engine, inspired
by the Django framework The Jinja template adds sandboxed execution for security reasons It features the automatic escape of HTML from XSS Vulnerability and uses inheritances
Flask is built on the above two libraries, the Jinja2
Flask is a microframework written in Python It is a
lightweight Web application framework, which uses the Werkzeug WSGI and Jinja2 template engine There is
no database abstraction layer or form validation layer, because the core is kept simple and supports extensions, which can add application features There are many different extensions available for Flask to support databases, upload files, for authentications, form validation, etc, which the user has to import and use
The Werkzeug WSGI (Web Server Gateway Interface)
WSGI is the interface between Web servers and Web applications for Python At present, Werkzeug is one of the most advanced WSGI utility modules It includes a powerful debugger, fully featured request and response objects, HTTP utilities to handle
Building Web Applications Using the Python Flask Microframework
Trang 36template engine and Werkzeug WSGI The remaining
decisions are left to you, as the developer You can choose
different extensions depending on your needs and interests
Let’s create a simple Web application using Flask
Flask installation
As a prerequisite, you need Python 2.6 or higher to get
started, and Pip, which is a tool to install and manage Python
packages Pip makes it easy for users to install and uninstall
Python packages in a single command For example:
$pip install PackageName
$pip uninstall PackageName
You have two ways to install Flask on your machine You
can either choose a virtual environment that allows you to work
in an isolated environment with a separate copy of Python, and
without worrying about affecting other projects if anything goes
wrong, or you can go for a direct installation of Python and Flask
on your native machine I have explained both the methods here
Let us first try the virtual environment using Pip Ubuntu
users can try it directly without Pip
$sudo pip install virtualenv
Ubuntu users should use:
$sudo apt-get install python-virtualenv
…to begin the virtual environment, and activate it by
issuing the following command:
$ virtualenv venv
$ venv/bin/activate
You can deactivate virtualenv as follows:
$deactivate
Once you have activated virtualenv, you are ready to
install Flask in the virtual environment Do so by using
Python package management
$pip install Flask
$pip install flask-script
You can install Flask directly in the system by avoiding the
virtual environment (sometimes Flask comes with Python):
$ pip install Flask
$ pip install flask-script
Once successfully installed, you can go ahead to create a
simple Web application
Our first app
Let’s create a directory for our application to start off with Flask, as follows:
$ mkdir myapp
$ cd myapp File structure:
myapp init .py manage.py templates/
about.html base.html index.html posts.html static/
css/
style.css
Create the directories and files which are listed above
init .py will create an object for application using
Flask and will be ready to run the app
manage.py will handle all URL routing properties and content
The templates directory contains all HTML pages needed for the applications and static contains all static resources like the style
sheet, images, etc; this is handled by the Jinja2 template engine
The above code will create an instance (app) for our app using the
Flask class The app.run method is used to run the local server with our application; we have imported the app object via manage.py, so
we can run the server from there
debug = True will automatically restart and reload the server if
any modifications are done to any file of the application
The app.run method is not actually needed here, because we are going to import app instance in the manage.py file and we can run the server from the manage file.
manage.py file
from flask import Flask, url_for, render_template from flask.ext.script import Manager, Server import os, sys
sys.path.append(os.path.abspath(os.path.join(os.path.
dirname(‘ file ’),’ ’)))
Trang 37sys, and app object is imported from the init .py file manage.py will take care of routing and content in our application Routing can be done using the @app.route()
method, which takes string arguments and will be appended to
the URL, e.g., @app.route(‘/index’) You can load the index page with the help of http://127.0.0.0:5000/index.
render_template will, by default, look for HTML pages in
the template directory, which takes the first argument as a page
name and passing key; value pairs are also possible in the render_ template method and values can be received using its key Manager module in Flask-script allows the user to create a new command Using the add_command we can set up the server and new command Here, we used runserver as our new command, and
server settings like debugging, reloading and application IP address Enabling debugger (use_debugger = True) is recommended for the purpose of testing and not for the production environment It will display an error message if something goes wrong, and reloader (use_reloader = True) will automatically reload the applications after we have made changes to the code
You can run the application using /manage.py runserver runserver is our own command, which has been created using the Manager module
<div class=”menu”>
<ul>
<li><a href=”{{url_for(‘index’)}}”>Home</a></ li>
<li><a href=”{{url_for(‘about’)}}”>About</a></ li>
<li><a href=”{{url_for(‘posts’)}}”>Post</a></ li>
return render_template(“index.html”, title = “Myapp home”)
#About page
@app.route(‘/about’) def about():
return render_template(“about.html”, title= “About”)
# load posts page and displays the content from the post array
@app.route(‘/posts’) def posts():
posts = [ { “title” : “Hello World”, “body” : “Welcome to python flask tutorial”
}, { “title” : “Sample post”, “body” : “Sample post for testing python flask “ }
] return render_template(“posts.html”, title = “Posts”, posts = posts)
# Create a new command ‘runserver’ using Manager and set host and enable debugger module.
# Debugger module only for developing not for production server
manager.add_command(‘runserver’, Server(
use_debugger = True, use_reloader = True, host = ‘127.0.0.1’
Import all necessary modules for our app The render_template
module in Flask uses the Jinja2 template, which automatically
locates the file from the templates directory in the app You can pass the template name and arguments as well url for is good for building
URLs Instead of hard code, the URLs passing the function names will take care of everything and arguments will also be accepted
The application path can be obtained from modules os and
Trang 38[1] http://en.wikipedia.org/wiki/Flask_(web_framework) [2] http://werkzeug.pocoo.org/
Jinja2 supports control and loop structures in the template
by using flowerbraces {{ }} base.html is the basic layout for
our Web application Other pages can simply extend this page
and the rest of the operations will be handled by Jinja2
The Jinja2 template allows inheritance, and the index file
inherits the basic layout from base.html.
In manage.py, the content for the post page is passed using
the render_template method and can be identified using its key
} container { margin-top: 20px;
margin-left: 70px;
width: 500px;
} title { background-color:#C2BABC;
}
Creating Web applications using Flask is very simple and needs little or no experience, when compared to other languages The server part will be handled by Flask, and
no extra server setup is needed Flask is known for its simplicity The core API is simple and is based on the Jinja2 template engine and the Werkzeug WSGI toolkit It allows developers to choose their own third party Python packages depending on their interests Using Flask is a good option for complex Web applications It makes the applications easy to understand and enables developers to work on different modules efficiently
Trang 39including ACL and LDAP support;
Employees with a central location for the latest apps needed by their department and optimised for their device;
Developers with an easy way to distribute mobile builds and elicit feedback from development and test team members
Device runtime
Device runtime is client-side runtime code that embeds server functionality within the target environment of deployed apps
IBM Worklight Server
The Java-based server is a scalable gateway between applications, external services, and the enterprise backend infrastructure The server contains security features to enable connectivity, multi-source data extraction and manipulation, authentication, the direct update of Web and hybrid apps, analytics and operational management functions
Worklight Console
This is a Web-based UI that allows application version management (installs, updates, disables and enables), and push management that provides administrative dashboards for
IBM Worklight offers platform portability of the application code, which is crucial during apps development Worklight enables the development of rich HTML 5 and hybrid apps using native code.
cross-IBM
IBM Worklight provides an open, comprehensive
and advanced mobile app development platform for smartphones and tablets It can be used to create all kinds of native, Web-based or hybrid mobile apps very easily It includes the IBM Worklight Studio―an Eclipse-based IDE (integrated development environment) in which all the coding and integration tasks are performed to develop
a fully functional mobile app
IBM Worklight consists of five main components as shown in Figure 1
Worklight Studio
This is one of the leading tools for cross-platform, hybrid development that maximises code reuse and enables per-device optimisation You can make apps for Android devices, the BlackBerry or other devices
Worklight Application Centre
The Worklight Application Centre enables companies to easily set up an app store for their enterprise and development teams
The application centre provides:
Administrators with fine-grained control over the distribution of mobile apps across the enterprise,
A Mobile App Development Platform
Trang 40deployed applications and installs adapters.
I am not going into too many details because a lot of
information can be found on the IBM website
Installing Worklight in Eclipse
Open Eclipse and go to the Help tab Click on it and select
Eclipse marketplace
A window will open; search for worklight and press
Enter You’ll find two products related to Worklight as
shown in Figure 2
Click on the Install button; it'll check the product and the
Confirm button will appear Click on it and the progress bar
of the download will be shown After installation, you will
see the Update and Uninstall buttons; this means you have
installed Worklight successfully
Installing the Android Development Kit (ADK)
Before installation, change the perspective of Eclipse Go to
the Window tab -> Open Perspective –> Java
After changing the perspective, open the window tab
again, and check whether the ADK is there If not, install the
ADK in the same way as we installed Worklight earlier
After installing the ADK, check the Android SDK
manager Some APIs would have been installed, while some
will have to be installed after some time as shown in Figure 3
Making an Android virtual device
Open the window tab and click on Android Virtual Device
Manager as shown in Figure 4 When a window opens,
press New and fill in the details of the device—in this
case your Android mobile phone Next, press OK, select
your newly created device and press the Start button You
will be asked about the real size of the screen/display
Now, press Launch After some time, a beautiful Android
screen will come up as shown in Figure 5
Making and deploying Android apps
Let’s start off by creating a Worklight project called
Mohit_Android Click Next and fill in the application’s
name, say mohit_android, and then press Finish This
Figure 1: Worklight’s structure
Worklight Console
Worklight Application Center Worklight Studio Device Runtime
Cross-Platform Compatibility Layer Encrypted and Syncable Storage Runtime Skinning Reporting for Statistics and Diagnositics
Server Integration Framework
Unified Push and SMS Notification
Public App Stores App Feedback Management
Development Team Provisioning Enterprise App Provisioning And Governance
and Mobile Trust
Adapter Library for
Backend Connectivity
Mashups and Service
Composition Direct Update
Mobile Web Apps
Unified Push Notification
Client-Side App Resources
JSON Translation
Geolocation Services Development and Operational Analytics
App Version Management
Figure 2: Eclipse marketplace
Figure 3: Android SDK manager
Figure 4: Android virtual device manager
Figure 5: Home screen
opens a screen as shown in Figure 6 While opening the screen, sometimes, it changes the perspective—which means
it sets it to‘Java EE’ if this was not set yet You can manually change the perspective
So we’ve finished with the setting up, and it's time to make our first app We are going to make a simple calculator
Step 1: Given below is the Java script code