'dev'에 해당되는 글 8건

  1. 2008/05/07 [MAVEN] third party jar install
  2. 2008/02/05 [스크랩]우분투 IP설정
  3. 2007/06/15 python_oracle
  4. 2007/05/29 python_file
  5. 2007/05/29 python_util
  6. 2007/05/29 python_string
  7. 2007/05/06 python 파일다루기
  8. 2007/05/06 python 명령행 옵션처리
mvn install:install-file
  -Dfile=<path-to-file>
  -DgroupId=<group-id>
  -DartifactId=<artifact-id>
  -Dversion=<version>
  -Dpackaging=<packaging>
  -DgeneratePom=true
Posted by joker

http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html

Ubuntu / Debian IP Configuration Files:

File: /etc/network/interfaces

Static IP example:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 208.88.34.106
        netmask 255.255.255.248
        broadcast 208.88.34.111
        network 208.88.34.104
        gateway 208.88.34.110

Dynamic IP (DHCP) example:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp

auto eth2
iface eth2 inet dhcp

auto ath0
iface ath0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
Interfaces:
  • lo: Loopback interface (network within your system without slowing down for the real ethernet based network)
  • eth0: First ethernet interface card
  • wlan0: First wireless network interface

Also see "man interfaces"




위의 내용을 바탕으로 이렇게 수정했더니...
뭐 굳이 공유기에서 강제로 IP를 수정하지 않아도 되는구만.
어쨌든 여러가지 방법을 확인했으니 그걸로 됐다^^

# The primary network interface

# using dhcp
#auto eth0
#iface eth0 inet dhcp

# using static ip
auto eth0
iface eth0 inet static
        address 192.168.0.5
        netmask 255.255.255.0
        broadcast 192.168.0.255
        gateway 192.168.0.1



출처: http://maxnim.tistory.com/1166706143?srchid=BR1f2975a6d4a0a1cc22fbdb5679c34849fefe9bccb

Posted by joker

python_oracle

dev/python 2007/06/15 14:31

Oracle module 소개

Oracle에 접속하기 위해서는 Oracle접속 모듈이 필요한데 이는 파이썬 소스코드를 통해 쉽게 Oracle 서버에 접근할 수 있도록 해주며 SQL명령어를 실행함으로써 얻은 결과를 파이썬코드에서 유용한 형태로 사용할 수 있도록 해준다. 파이썬을 통해 Oracle에 접근하기 위해서 본 글에서는 cx_Oracle 모듈을 사용했다. cx_Oracle모듈은 다음 싸이트에서 최신버전을 다운받을 수 있다. http://sourceforge.net/projects/cx-oracle/ 설치되어 있는 파이썬 버전과 사용하고있는 오라클 버전에 맞는 모듈을 다운받아 설치하면 된다. 그밖에 다른 모듈을 사용할 경우 다음 페이지를 참조하여 적절한 모듈은 사용하면 된다. http://www.python.org/topics/database/modules.html

설치방법

리눅스

$ tar -xzvf cx_Oracle-4.3.1.tar.gz

$ cd cx_Oracle-4.3.1

$ python setup.py build

$ python setup.py install

윈도우

다운받은 실행파일을 실행하면 python설치 디렉토리를 찾아 자동으로 설치된다. cx_Oracle-4.3.1-win32-10g-py25.exe

Oracle 접속방법

  • 1.먼저 설치된 cx_Oracle모듈을 import한다.

>>> import cx_Oracle

  • 2.Database에 접속한다.
  • connect( [user, password, dsn, mode, handle, pool, threaded, twophase])
  • 일반적인 접속을 위해서는 id와 passwd 그리고 dsn(data source name:TNSNAMES.ora파일 참고)이 필요하다.
  • 추가적인 파라미터는 필요에 따라 접속시 지정할 수 있으며 일반적인 접속을 위해서 아래와 같이 접속하였다.

>>>orcl = cx_Oracle.connect('id/passwd@dsn')

예제코드

  1. >>> import cx_Oracle
    >>> orcl = cx_Oracle.connect('id/passwd@dsn')
    >>> curs = orcl.cursor()
    >>> curs.execute('select * from blogmore where btype=\'BEST\'')
    >>> row = curs.fetchone() #상위 1개의 row만 가져온다.
    >>>print row  #해당 row가 turple형태로 출력된다.
    (155, 'BEST', 'antiright', '\xb4\xeb\xb8\xb6\xbf\xd5', '\xb4\xeb\xb8\xb6\xbf\xd5 \xb9\xe6\xb6\xfb\xb1\xe2', None, None, 'http://cfs7.blog.daum.net/upload_control/download.blog?fhandle=MDNPcmlAZnM3LmJsb2cuZGF1bS5uZXQ6L1BST0ZJTEUvMC8wLmpwZy50aHVtYg==&filename=0.jpg-', datetime.datetime(2006, 12, 4, 19, 45, 33))
    >>> print row[0], row[1]
    155 BEST
    >>> rows = curs.fetchall() #모든 row를 가져온다.
    >>> print rows #검색된 모든row가 list형태로 출력된다.
    
    >>> print rows[0]
    첫번째 row 출력
    >>> print rows[0][1]
    첫번째 row의 첫번째 필드 출력
    

참고문헌

http://www.oracle.com/technology/pub/articles/devlin-python-oracle.html

http://www.python.net/crew/atuining/cx_Oracle/html/front.html

이 글은 스프링노트에서 작성되었습니다.

Posted by joker

python_file

dev/python 2007/05/29 00:51

file.close(), file.read([size]) , file.readline()

file.readlines(): 전체라인을 readline()을 이용하여 읽어들인 라인을 리스트에 넣어서 리턴한다.

file.write(str): 문자열 str을 파일에 쓴다.

file.writeline(str): 문자열 리스트를 파일에 쓴다. 줄바꾸기가 자동으로 삽입되지는 않는다.

file.seek(offset,[whence]): whence의 기본 값은 0이다. 0이면 시작 기준, 1이면 현재 위치 기준, 2이민 끝 기준에서 offset만큼 떨어진 위치에 파일 포인터를 위치시킨다.

file.tell(): 파일의 현재위치를 리턴한다.

file.flush(): 버퍼가 다 채워지지 않았어도 내부 버퍼의 내용을 파일에 보낸다.

file.fileno(): file 객체의 파일 기술자(File Descriptor)(정수)를 리턴한다.

file.truncate([size])파일 크기를 지정된 크기로 잘라버림. 인수를 주지 않으면 현재 위치에서 자른다.

file.mode: 파일이 오픈된 모드, file.closed: 1 or 0을 리턴, file.name: open()할 때 사용된 파일 이름


이 글은 스 프 링 노 트에서 작성되었습니다.

Posted by joker

python_util

dev/python 2007/05/29 00:26

  #1 디렉토리의 파일목록 얻기
glob모듈의 glob함수 사용: 와일드카드문자 ?(임의의문자 1개와 매칭),* 를 지원한다.
ex)import glob
glob.glob('./[0-9].*')

#2 파일의 추가정보 알아내기

isfile(path)- path가 일반 파일이면 True 리턴
isdir(path)- path가 디렉토리이면 True 리턴
islink(path), ismount(path), exist(path)

파일크기, 접근시간
os.path.getsize('py.py') //실제파일 사이지(윈도우에서는 파일읽기를 통해 계산하는 사이즈와 다를수 있음)

import time
os.path.getatime(path)  #접근시간
os.path.getatime(path)  #수정시간

#3 경로명 다루기
import os
p=os.path.abspath('a.log')   #상대경로를 절대경로로
'C:\\python23\\t.py'
os.path.split(p)
('C:\\python23', 't.py') #(디렉토리와 파일을 분리)
os.path.join('C:\\python23', 't.py') #(디렉토리와 파일을 결합)

#4  URL다루기
urlparse함수는 아래와 같이 분리하여 튜플을 리턴
(addressing, scheme, network location, path, parameter, query, fragment, identifier)
ex)
>>> import urlparse
>>> a='http://3355.daum.net/daum/search/top/TotalList?q=스파이더맨3&skey='
>>> x=urlparse.urlparse(a)
>>>x
('http', '3355.daum.net', '/daum/search/top/TotalList', '', 'q=\xbd\xba\xc6\xc4\xc0\xcc\xb4\xf5\xb8\xc73&skey=', '')
>>> urlparse.urlunparse(x)
'http://3355.daum.net/daum/search/top/TotalList?q=\xbd\xba\xc6\xc4\xc0\xcc\xb4\xf5\xb8\xc73&skey='
>>> urlparse.urljoin(a, 'SearchTop')
'http://3355.daum.net/daum/search/top/SearchTop'
>>> urlparse.urljoin(a, '/')
'http://3355.daum.net/'




이 글은 스 프 링 노 트에서 작성되었습니다.

Posted by joker

python_string

dev/python 2007/05/29 00:26

String method

#1 문자열 찾기

 upper(), lower()  대소문자 변환

find(s),rfind(s), index(s)  문자열을 찾으면 시작 인덱스 반환, 없으면 -1, index는 없으면 Value error를 발생시킴

find는 왼쪽을 시작위치로, rfind는 오른쪽을 시작위치로 (검색시작위치 지정가능)

#2 편집및 치환

rstrip(), lstrip(), strip() 공백제거

 replace(a,b) 문자열 치환

split(str) 문자열을 분할 =>s.split('\n')라인단위로 분리

join(str) 문자열 병합 '\n'.join(list)

center(len), rjust(len). ljust(len)  =>주어진 길이의 문자에서 가운데 오른쪽 왼쪽 정렬

#3문자열 질의

isalnum(), isalpha(), istitle(),isdigit(),islower, isupper(),isspace(),

true or false 리턴


#string 모듈

모듈상수

digits, octdigits, hexdigits, letters, lowercase, uppercase, punctuation, printable, whitespace

모듈함수

capwords(s) - 각 단어의 첫문자를 대문자로 , zfill(s, n) - 왼쪽의 빈자리를 0으로 채운다.


 #문서 문자열

모듈이나

이 글은 스 프 링 노 트에서 작성되었습니다.

Posted by joker
TAG Python, string
#1 디렉토리의 파일목록 얻기
glob모듈의 glob함수 사용: 와일드카드문자 ?(임의의문자 1개와 매칭),* 를 지원한다.
ex)import glob
glob.glob('./[0-9].*')

#2 파일의 추가정보 알아내기

isfile(path)- path가 일반 파일이면 True 리턴
isdir(path)- path가 디렉토리이면 True 리턴
islink(path), ismount(path), exist(path)

파일크기, 접근시간
os.path.getsize('py.py')

import time
os.path.getatime(path)  #접근시간
os.path.getatime(path)  #수정시간

#3 경로명 다루기
import os
p=os.path.abspath('a.log')   #상대경로를 절대경로로
'C:\\python23\\t.py'
os.path.split(p)
('C:\\python23', 't.py') #(디렉토리와 파일을 분리)
os.path.join('C:\\python23', 't.py') #(디렉토리와 파일을 결합)

#4  URL다루기
urlparse함수는 아래와 같이 분리하여 튜플을 리턴
(addressing, scheme, network location, path, parameter, query, fragment, identifier)
ex)
>>> import urlparse
>>> a='http://3355.daum.net/daum/search/top/TotalList?q=스파이더맨3&skey='
>>> x=urlparse.urlparse(a)
>>>x
('http', '3355.daum.net', '/daum/search/top/TotalList', '', 'q=\xbd\xba\xc6\xc4\xc0\xcc\xb4\xf5\xb8\xc73&skey=', '')
>>> urlparse.urlunparse(x)
'http://3355.daum.net/daum/search/top/TotalList?q=\xbd\xba\xc6\xc4\xc0\xcc\xb4\xf5\xb8\xc73&skey='
>>> urlparse.urljoin(a,'SearchTop')
'http://3355.daum.net/daum/search/top/SearchTop'
>>> urlparse.urljoin(a,'/')
'http://3355.daum.net/'





Posted by joker
명령행 옵션처리
#getopt.getopt(명령행인수리스트, 옵션문자)
#옵션문자에 :이 사용된다면 추가인수를 받아들인다는 의미임

ex)
python option.py -a x -b y -c z  arg1 arg2 arg3

options, args  = getopt.getopt(sys.argv[1:], 'a:b:c:')
for op, p in options:
    if op == '-a':print 'option a', p
    if op == '-b':print 'option b', p
    if op == '-c':print 'option c', p
Posted by joker