Tuesday 12 June 2012

Launchpad Configuration

1) Launchpad Account Configuration
=========================================
https://launchpad.net
Display Name must be like: Turkesh Patel (Open ERP)
Name must be like: tpa-openerp

2) SSH key generation
=======================
Step 1: Open the terminal and type:
ssh-keygen -t rsa
Step 2: When prompted, press Enter to accept the default file name for your key.
Step 3: Next, Enter passphrase (empty for no passphrase):
Press Enter without writing anything (2 times)
Now you need to upload the public portion of your SSH key to Launchpad.
Step 4: Visit your SSH keys page. (https://launchpad.net/people/+me/+editsshkeys)
Step 5: Run following command on terminal
cat ~/.ssh/id_rsa.pub
Copy the output (which is your Public Key)
Step 6: Paste your public key into the text box and then click the Import public key button to continue.

3) Bzr Configuration
==========================
Execute Following Commands in Terminal
bzr whoami "Turkesh Patel (Open ERP) <tpa@tinyerp.com>"
bzr launchpad-login "tpa-openerp"

4) About OpenERP teams and projects
=========================================
https://launchpad.net/openobject

OpenERP Projects
--------------------
Server: https://launchpad.net/openobject-server
Client: https://launchpad.net/openobject-client
Addons: https://launchpad.net/openobject-addons
Web Client: https://bugs.launchpad.net/openobject-client-web

OpenERP teams
---------------
OpenERP Committers: https://launchpad.net/~openerp-commiter
OpenERP R&D Team: https://launchpad.net/~openerp-dev
OpenERP Core Team: https://launchpad.net/~openerp

Branches
---------
Addons: https://code.launchpad.net/openobject-addons
Server: https://code.launchpad.net/openobject-server
Client: https://code.launchpad.net/openobject-client

Friday 16 September 2011

Python script for convert Georgion date to the Hijari date & Hijari date to Georgion Date



############################################################
#
#use constant IslamicEpoch => 227014
#
############################################################
IslamicEpoch = 227014

hijri_date = {'year':'', 'month':'', 'date':'','hmonth':''}
eng_date = {'year':'', 'month':'', 'date':'','emonth':''}

def get_hijri_month(m):
    n_month = False

    if m==1:
        n_month = "Muharram"

    if m==2:
        n_month = "Safar"

    if m==3:
        n_month = "Rabi'ul Awal"

    if m==4:
        n_month = "Rabi'ul Akhir"

    if m==5:
        n_month = "Jamadil Awal"

    if m==6:
        n_month = "Jamadil Akhir"

    if m==7:
        n_month = "Rajab"

    if m==8:
        n_month = "Sha'ban"

    if m==9:
        n_month = "Ramadhan"

    if m==10:
        n_month = "Shawwal"

    if m==11:
        n_month = "Zul Qida"

    if m==12:
        n_month = "Zul Hijja"

    return  n_month


def get_english_month(m):
    eMonth = False

    if m==1:
        eMonth = "January"

    if m==2:
        eMonth = "February"

    if m==3:
        eMonth = "March"

    if m==4:
        eMonth = "April"

    if m==5:
        eMonth = "May"

    if m==6:
        eMonth = "June"

    if m==7:
        eMonth = "July"

    if m==8:
        eMonth = "August"

    if m==9:
        eMonth = "September"

    if m==10:
        eMonth = "October"

    if m==11:
        eMonth = "November"

    if m==12:
        eMonth = "December"

    return eMonth

def lastDayOfGregorianMonth(month, year):
    # Compute the last date of the month for the Gregorian calendar.
    res = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    if (month == 2):
        if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
            return 29
    i = (month-1)
    return res[i]


def Gregorian2Absolute(day, month, year):
    # Computes the absolute date from the Gregorian date.
    N = day                          # days this month
    for m in range(1,month): # days in prior months this year
        N = N + lastDayOfGregorianMonth(m, year)
   
    return int(N                        # days this year
               + 365 * (year - 1)       # days in previous years ignoring leap days
               + (year - 1) / 4         # Julian leap days before this year...
               - (year - 1) / 100       # ...minus prior century years...
               + (year - 1) / 400)     # ...plus prior years divisible by 400

def Absolute2Gregorian(d):
    # Computes the Gregorian date from the absolute date.
    # Search forward year by year from approximate year
    year = int(d / 366 + 0.5)

    while (d >= Gregorian2Absolute(1,1,year+1)):
        year = year + 1

    # Search forward month by month from January
    month = 1
    while (d >= Gregorian2Absolute(lastDayOfGregorianMonth(month, year), month, year)):
        month = month + 1
    day = d - Gregorian2Absolute(1, month, year)
#    return [day, month, year]
    eng_date["year"] = year
    eng_date["month"] = month
    eng_date["date"] = day
    eng_date["emonth"] = get_english_month(month)
    return eng_date


def IslamicLeapYear(year):
    # True if year is an Islamic leap year
    if ((((11 * year) + 14) % 30) < 11):
        return 1
    return 0

def lastDayOfIslamicMonth(month, year):
    # Last day in month during year on the Islamic calendar.
    if (month % 2 == 1) or (month == 12 and IslamicLeapYear(year)):
        return 30
    return 29

def Islamic2Absolute(day, month, year):
    # Computes the absolute date from the Islamic date.
    return int(day                      # days so far this month
               + 29 * (month - 1)       # days so far...
               + int(month /2)          # ...this year
               + 354 * (year - 1)       # non-leap days in prior years
               + (3 + (11 * year)) / 30 # leap days in prior years
               + IslamicEpoch)          # days before start of calendar

def Absolute2Islamic(d):
    # Computes the Islamic date from the absolute date.
    if (d <= IslamicEpoch):
        # Date is pre-Islamic
        month = 0
        day = 0
        year = 0
    else:
        # Search forward year by year from approximate year
        year = int((d - IslamicEpoch) / 355)
    while (d >= Islamic2Absolute(1,1,year+1)):
        year = year + 1
    # Search forward month by month from Muharram
    month = 1
    while (d > Islamic2Absolute(lastDayOfIslamicMonth(month,year), month, year)):
        month = month + 1
    day = d - Islamic2Absolute(0, month, year) +1

    hijri_date["year"] = year
    hijri_date["month"] = month
    hijri_date["date"] = day
    hijri_date["hmonth"] = get_hijri_month(month)
    return hijri_date


print "in which you want to convert \n for eng to hijri 1\n for hijri to eng 2"
n = raw_input()

print "Enter Year"
yy = raw_input()
print "Enter Month"
mm = raw_input()
print "Enter date"
dd= raw_input()

if int(n) == 1:
    date_n=Absolute2Islamic(Gregorian2Absolute(int(dd),int(mm),int(yy)))
    print "nowwwwwwwww Hijri",date_n

if int(n) == 2:
    date_n=Absolute2Gregorian(Islamic2Absolute(int(dd),int(mm),int(yy)))
    print "nowwwwwwwww eng",date_n

Python script for convert Georgion date to the Nepali date & Nepali date to Georgion Date

#     **
#     * currently can only calculate the date between BS 2000-2089
#     * currently can only calculate the date between AD 1944-2033...
#     *
#     **


import time
from datetime import datetime
from dateutil.relativedelta import relativedelta

bs = [
    [0,[2000,30,32,31,32,31,30,30,30,29,30,29,31]],
    [1,[2001,31,31,32,31,31,31,30,29,30,29,30,30]],
    [2,[2002,31,31,32,32,31,30,30,29,30,29,30,30]],
    [3,[2003,31,32,31,32,31,30,30,30,29,29,30,31]],
    [4,[2004,30,32,31,32,31,30,30,30,29,30,29,31]],
    [5,[2005,31,31,32,31,31,31,30,29,30,29,30,30]],
    [6,[2006,31,31,32,32,31,30,30,29,30,29,30,30]],
    [7,[2007,31,32,31,32,31,30,30,30,29,29,30,31]],
    [8,[2008,31,31,31,32,31,31,29,30,30,29,29,31]],
    [9,[2009,31,31,32,31,31,31,30,29,30,29,30,30]],
    [10,[2010,31,31,32,32,31,30,30,29,30,29,30,30]],
    [11,[2011,31,32,31,32,31,30,30,30,29,29,30,31]],
    [12,[2012,31,31,31,32,31,31,29,30,30,29,30,30]],
    [13,[2013,31,31,32,31,31,31,30,29,30,29,30,30]],
    [14,[2014,31,31,32,32,31,30,30,29,30,29,30,30]],
    [15,[2015,31,32,31,32,31,30,30,30,29,29,30,31]],
    [16,[2016,31,31,31,32,31,31,29,30,30,29,30,30]],
    [17,[2017,31,31,32,31,31,31,30,29,30,29,30,30]],
    [18,[2018,31,32,31,32,31,30,30,29,30,29,30,30]],
    [19,[2019,31,32,31,32,31,30,30,30,29,30,29,31]],
    [20,[2020,31,31,31,32,31,31,30,29,30,29,30,30]],
    [21,[2021,31,31,32,31,31,31,30,29,30,29,30,30]],
    [22,[2022,31,32,31,32,31,30,30,30,29,29,30,30]],
    [23,[2023,31,32,31,32,31,30,30,30,29,30,29,31]],
    [24,[2024,31,31,31,32,31,31,30,29,30,29,30,30]],
    [25,[2025,31,31,32,31,31,31,30,29,30,29,30,30]],
    [26,[2026,31,32,31,32,31,30,30,30,29,29,30,31]],
    [27,[2027,30,32,31,32,31,30,30,30,29,30,29,31]],
    [28,[2028,31,31,32,31,31,31,30,29,30,29,30,30]],
    [29,[2029,31,31,32,31,32,30,30,29,30,29,30,30]],
    [30,[2030,31,32,31,32,31,30,30,30,29,29,30,31]],
    [31,[2031,30,32,31,32,31,30,30,30,29,30,29,31]],
    [32,[2032,31,31,32,31,31,31,30,29,30,29,30,30]],
    [33,[2033,31,31,32,32,31,30,30,29,30,29,30,30]],
    [34,[2034,31,32,31,32,31,30,30,30,29,29,30,31]],
    [35,[2035,30,32,31,32,31,31,29,30,30,29,29,31]],
    [36,[2036,31,31,32,31,31,31,30,29,30,29,30,30]],
    [37,[2037,31,31,32,32,31,30,30,29,30,29,30,30]],
    [38,[2038,31,32,31,32,31,30,30,30,29,29,30,31]],
    [39,[2039,31,31,31,32,31,31,29,30,30,29,30,30]],
    [40,[2040,31,31,32,31,31,31,30,29,30,29,30,30]],
    [41,[2041,31,31,32,32,31,30,30,29,30,29,30,30]],
    [42,[2042,31,32,31,32,31,30,30,30,29,29,30,31]],
    [43,[2043,31,31,31,32,31,31,29,30,30,29,30,30]],
    [44,[2044,31,31,32,31,31,31,30,29,30,29,30,30]],
    [45,[2045,31,32,31,32,31,30,30,29,30,29,30,30]],
    [46,[2046,31,32,31,32,31,30,30,30,29,29,30,31]],
    [47,[2047,31,31,31,32,31,31,30,29,30,29,30,30]],
    [48,[2048,31,31,32,31,31,31,30,29,30,29,30,30]],
    [49,[2049,31,32,31,32,31,30,30,30,29,29,30,30]],
    [50,[2050,31,32,31,32,31,30,30,30,29,30,29,31]],
    [51,[2051,31,31,31,32,31,31,30,29,30,29,30,30]],
    [52,[2052,31,31,32,31,31,31,30,29,30,29,30,30]],
    [53,[2053,31,32,31,32,31,30,30,30,29,29,30,30]],
    [54,[2054,31,32,31,32,31,30,30,30,29,30,29,31]],
    [55,[2055,31,31,32,31,31,31,30,29,30,29,30,30]],
    [56,[2056,31,31,32,31,32,30,30,29,30,29,30,30]],
    [57,[2057,31,32,31,32,31,30,30,30,29,29,30,31]],
    [58,[2058,30,32,31,32,31,30,30,30,29,30,29,31]],
    [59,[2059,31,31,32,31,31,31,30,29,30,29,30,30]],
    [60,[2060,31,31,32,32,31,30,30,29,30,29,30,30]],
    [61,[2061,31,32,31,32,31,30,30,30,29,29,30,31]],
    [62,[2062,30,32,31,32,31,31,29,30,29,30,29,31]],
    [63,[2063,31,31,32,31,31,31,30,29,30,29,30,30]],
    [64,[2064,31,31,32,32,31,30,30,29,30,29,30,30]],
    [65,[2065,31,32,31,32,31,30,30,30,29,29,30,31]],
    [66,[2066,31,31,31,32,31,31,29,30,30,29,29,31]],
    [67,[2067,31,31,32,31,31,31,30,29,30,29,30,30]],
    [68,[2068,31,31,32,32,31,30,30,29,30,29,30,30]],
    [69,[2069,31,32,31,32,31,30,30,30,29,29,30,31]],
    [70,[2070,31,31,31,32,31,31,29,30,30,29,30,30]],
    [71,[2071,31,31,32,31,31,31,30,29,30,29,30,30]],
    [72,[2072,31,32,31,32,31,30,30,29,30,29,30,30]],
    [73,[2073,31,32,31,32,31,30,30,30,29,29,30,31]],
    [74,[2074,31,31,31,32,31,31,30,29,30,29,30,30]],
    [75,[2075,31,31,32,31,31,31,30,29,30,29,30,30]],
    [76,[2076,31,32,31,32,31,30,30,30,29,29,30,30]],
    [77,[2077,31,32,31,32,31,30,30,30,29,30,29,31]],
    [78,[2078,31,31,31,32,31,31,30,29,30,29,30,30]],
    [79,[2079,31,31,32,31,31,31,30,29,30,29,30,30]],
    [80,[2080,31,32,31,32,31,30,30,30,29,29,30,30]],
    [81,[2081, 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30]],
    [82,[2082, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30]],
    [83,[2083, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30]],
    [84,[2084, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30]],
    [85,[2085, 31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30]],
    [86,[2086, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30]],
    [87,[2087, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30]],
    [88,[2088, 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30]],
    [89,[2089, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30]],
    [90,[2090, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30]]
    ]

nep_date = {'year':'', 'month':'', 'date':'', 'day':'','nmonth':'','num_day':''}
eng_date = {'year':'', 'month':'', 'date':'', 'day':'','emonth':'','num_day':''}
debug_info = "";


# Calculates wheather english year is leap year or not
#
# @param integer year
# @return boolean
#
def is_leap_year(year):

    a = year
    if (a%100==0):
        if(a%400==0):
            return True
        else:
            return False

    else:
        if (a%4==0):
            return True
        else:
            return False


def get_nepali_month(m):
    n_month = False

    if m==1:
        n_month = "Baisakh"

    if m==2:
        n_month = "Jestha"

    if m==3:
        n_month = "Ashadh"

    if m==4:
        n_month = "Shrawan"

    if m==5:
        n_month = "Bhadra"

    if m==6:
        n_month = "Ashwin"

    if m==7:
        n_month = "Kartik"

    if m==8:
        n_month = "Mangshir"

    if m==9:
        n_month = "Poush"

    if m==10:
        n_month = "Magh"

    if m==11:
        n_month = "Falgun"

    if m==12:
        n_month = "Chaitra"

    return  n_month


def get_english_month(m):
    eMonth = False

    if m==1:
        eMonth = "January"

    if m==2:
        eMonth = "February"

    if m==3:
        eMonth = "March"

    if m==4:
        eMonth = "April"

    if m==5:
        eMonth = "May"

    if m==6:
        eMonth = "June"

    if m==7:
        eMonth = "July"

    if m==8:
        eMonth = "August"

    if m==9:
        eMonth = "September"

    if m==10:
        eMonth = "October"

    if m==11:
        eMonth = "November"

    if m==12:
        eMonth = "December"

    return eMonth


def get_day_of_week(day):       

    if day==1:
        day = "Sunday"
   
    if day==2:
        day = "Monday"
   
    if day==3:
        day = "Tuesday"

    if day==4:
        day = "Wednesday"

    if day==5:
        day = "Thursday"

    if day==6:
        day = "Friday"

    if day==7:
        day = "Saturday"

    return day


def is_range_eng(yy, mm, dd):
    if yy<1944 or yy>2033:
        debug_info = "Supported only between 1944-2032"
        print debug_info
        return False

    if mm<1 or mm >12:
        debug_info = "Error! value 1-12 only"
        print debug_info
        return False

    if dd<1 or dd >31:
        debug_info = "Error! value 1-31 only"   
        print debug_info       
        return False

    return True


def is_range_nep(yy, mm, dd):       
    if(yy<2000 or yy>2089):
        debug_info="Supported only between 2000-2089"
        print debug_info
        return False

    if(mm<1 or mm >12):
        debug_info="Error! value 1-12 only"
        print debug_info
        return False
   
    if(dd<1 or dd >32):
        debug_info="Error! value 1-31 only"
        print debug_info   
        return False       

    return True


#     **
#     * currently can only calculate the date between AD 1944-2033...
#     *
#     * @param unknown_type yy
#     * @param unknown_type mm
#     * @param unknown_type dd
#     * @return unknown
#     **
   
def eng_to_nep(yy,mm,dd):

    if (is_range_eng(yy, mm, dd) == False):

        return False

    else:           

        #english month data.
        month = [31,28,31,30,31,30,31,31,30,31,30,31]
        lmonth = [31,29,31,30,31,30,31,31,30,31,30,31]

        def_eyy = 1944        #spear head english date...
        def_nyy = 2000
        def_nmm = 9
        def_ndd = 17-1        #spear head nepali date...
        total_eDays=0
        total_nDays=0
        a=0
        day=7-1                #all the initializations...
        m = 0
        y = 0
        i =0
        j = 0
        numDay=0
       
        # count total no. of days in-terms of year
        for i in range(0,(int(yy)-def_eyy)):    #total days for month calculation...(english)
            if(is_leap_year(def_eyy+i)==1):
                for j in range(0,12):
                    total_eDays += lmonth[j]
            else:
                for j in range(0,12):
                    total_eDays += month[j]

        # count total no. of days in-terms of month                   
        for i in range(0, mm-1):       
            if(is_leap_year(yy)==1):
                total_eDays += lmonth[i]
            else:
                total_eDays += month[i]
       
        # count total no. of days in-terms of date
        total_eDays += dd
       
       
        i = 0
        j = def_nmm                   
        total_nDays = def_ndd
        m = def_nmm
        y = def_nyy
       
        # count nepali date from array
        while(total_eDays != 0):
            #print " i and j",i,j
            a = bs[i][1][j]
            total_nDays = total_nDays + 1                #count the days
            day = day + 1                                #count the days interms of 7 days
            if(total_nDays > a):
                m = m + 1
                total_nDays = 1
                j = j + 1

            if day > 7:
                day = 1
            if m > 12:
                y = y + 1
                m = 1

            if j > 12:
                j = 1
                i = i + 1

            total_eDays = total_eDays - 1
       
        numDay=day
       
        nep_date["year"] = y
        nep_date["month"] = m
        nep_date["date"] = total_nDays
        nep_date["day"] = get_day_of_week(day)
        nep_date["nmonth"] = get_nepali_month(m)
        nep_date["num_day"] = numDay
        return nep_date


   
#     **
#     * currently can only calculate the date between BS 2000-2089
#     *
#     * @param unknown_type yy
#     * @param unknown_type mm
#     * @param unknown_type dd
#     * @return unknown
#     **

def nep_to_eng(yy,mm,dd):
   
    def_eyy = 1943
    def_emm=4
    def_edd=14-1        # init english date.
    def_nyy = 2000
    def_nmm = 1
    def_ndd = 1        # equivalent nepali date.
    total_eDays=0
    total_nDays=0
    a=0
    day=4-1        # initializations...
    m = 0
    y = 0
    i=0
    k = 0
    numDay = 0
    j=0
   
    month = [0,31,28,31,30,31,30,31,31,30,31,30,31]
    lmonth = [0,31,29,31,30,31,30,31,31,30,31,30,31]
   
    if is_range_nep(yy, mm, dd)==False:
        return False
       
    else :
       
        # count total days in-terms of year
        for i in range(0, (yy-def_nyy)):   
            for j in range(1,13):
                total_nDays += bs[k][1][j]
            k = k + 1
       
        # count total days in-terms of month           
        for j in range(1,mm):
            total_nDays += bs[k][1][j]


        # count total days in-terms of dat
        total_nDays += dd           
       
        #calculation of equivalent english date...
        total_eDays = def_edd
        m = def_emm
        y = def_eyy
        while(total_nDays != 0):
            if(is_leap_year(y)):
                a = lmonth[m]

            else:
                a = month[m]

            total_eDays = total_eDays + 1
            day = day + 1

            if(total_eDays > a):
                m = m + 1
                total_eDays = 1

                if(m > 12):
                    y = y + 1
                    m = 1

            if(day > 7):
                day = 1;
            total_nDays = total_nDays - 1

        numDay = day

        eng_date["year"] = y                   
        eng_date["month"] = m                   
        eng_date["date"] = total_eDays       
        eng_date["day"] = get_day_of_week(day)                   
        eng_date["emonth"] = get_english_month(m)             
        eng_date["num_day"] = numDay           
       
        return eng_date           



#print "Enter Date in (yy/mm/dd) format"
print "in which you want to convert \n for eng to napali 1\n for nepali to eng 2"
n = raw_input()

print "Enter Year"
yy = raw_input()
print "Enter Month"
mm = raw_input()
print "Enter date"
dd= raw_input()

if int(n) == 1:
    date_n=eng_to_nep(int(yy),int(mm),int(dd))
    print "nowwwwwwwww nep",date_n

if int(n) == 2:
    date_n=nep_to_eng(int(yy),int(mm),int(dd))
    print "nowwwwwwwww eng",date_nhttp://turkeshpatel.blogspot.com/

hit counter