Senin, 03 Maret 2014

Another app is currently holding the yum lock; waiting for it to exit

Saat install dengan menggunakan yum secara berkesinambungan Oracle Linux saya memunculkan pesan
Another app is currently holding the yum lock; waiting for it to exit
Contohnya setelah selesai menjalankan
yum install binutils -y
maka saya lanjutkan dengan menjalankan
yum install compat-libcap1 -y
sesaat kemudian muncul pesan
Another app is currently holding the yum lock; waiting for it to exit…
The other application is: PackageKIt
Jika diperiksa menggunakan perintah ps -ef | grep package, maka akan muncul baris /usr/sbin/packagekitd. Untuk menghilangkan masalah
Another app is currently holding the yum lock; waiting for it to exit
yang berulang setiap yum install, maka kita bisa mengedit config di /etc/yum/pluginconf.d/refresh-packagekit.conf dari
[main]
enabled=1
menjadi
[main]
enabled=0

Kamis, 20 Februari 2014

Mengamankan Bash Script dengan Python Script

Contoh Python Script untuk mengamankan Bash Shell Script agar tidak diubah, contohnya bash script untuk backup, eksekusi yang menyimpan password (selanjutnya file python dapat dicompile untuk menghasilkan .pyc)
import tempfile
import subprocess

script_one = '''\
echo "Hello world!"
echo "This is a bash script. :-)"
'''

def run_script(script):
    with tempfile.NamedTemporaryFile() as scriptfile:
        scriptfile.write(script)
        scriptfile.flush()
        subprocess.call(['/bin/bash', scriptfile.name])
        print('temporary file' + scriptfile.name)

run_script(script_one)

Encrypt File on Red Hat Enterprise Linux Server release 6.4 (Santiago)

Sesudah menghasilkan file tar.gz, bisa saja kita menginginkan agar file hasil kompresi juga diberikan password. Jika dibandingan dengan menggunakan 7zip, tentunya lebih mudah karena di-command line-nya sudah tersedia. Untuk file tar.gz maupun file lain, bisa diencrypt dengan openssl,
orabackup=/u01/app/oracle/backups
foldername=$(date +%Y%m%d)
openssl aes-256-cbc -in "$orabackup"/dumps/dp"$foldername".tgz -out "$orabackup"/dumps/dp"$foldername".tgz.enc -k katakunci
Untuk decryptnya,
openssl aes-256-cbc -d -in "$orabackup"/dumps/dp"$foldername".tgz.enc -out "$orabackup"/dumps/dp"$foldername".tgz -k katakunci
Selain menggunakan, hasil googling dapat juga menggunakan gpg, namun BalCod sudah memilih untuk menggunakan openssl. ^_^

Jumat, 03 Januari 2014

Python - Install html 1.16

  1. download html 1.16
  2. extract and run python setup.py build install
  3. got error message
    Traceback (most recent call last):
      File "setup.py", line 12, in 
        long_description = __doc__.decode('utf8'),
    AttributeError: 'str' object has no attribute 'decode'
    
  4. find line 12 in setup.py
  5. remark this line #long_description = __doc__.decode('utf8'),
  6. run againpython setup.py build install
  7. hurra

Senin, 09 Desember 2013

Convert time.struct_time to datetime in Python

>>> structTime = time.localtime()
>>> datetime.datetime(*structTime[:6])
datetime.datetime(2009, 11, 8, 20, 32, 35)

Tips for Python


  1. Use [Ctrl+Alt+Enter] to configure interactive console in Eclipse-PyDev (Console for currently active editor)
  2. Use print('x',...) to print without newline concate with list
    print('x', os.listdir(self.right))
    
  3. Enable PyDev Interactive Console while Debugging Session
    To enable, go to Window | Preferences | PyDev | Interactive Console and check 'Connect console to Debug Session?
  4. If you get an error message like this
    Assignment to reserved built-in symbos: abs
    , then then you can add comments
    # @ReservedAssignment
     at the end of the line so that it is no longer regarded as an error
  5. ...

Get Modification Time of File in Python

'''
Created on Dec 9, 2013

@author: BalonCoding
'''
import os
  
fileName = 'c:\\fm\\fmb\\MTR00035.fmb'
#using os.stat.st_mtime
st=os.stat(fileName)    
mtime=st.st_mtime
print("mtime (using os.stat.st_mtime) = " + str(mtime))
#mtime (using os.stat.st_mtime) = 1141933677.28125

#using os.path.getmtime
print("mtime (using os.path.getmtime) = " + str(os.path.getmtime(fileName)))
#mtime (using os.path.getmtime) = 1141933677.28125


############################################################################################
import datetime

#using datetime.datetime
print("mtime (using datetime.datetime) = {}".format(datetime.datetime.fromtimestamp(mtime)))
#mtime (using datetime.datetime) = 2006-03-10 02:47:57.281250


############################################################################################
import stat, time
print("mtime (using time.ctime ) = {}".format(time.ctime(st[stat.ST_MTIME])))
#mtime (using time.ctime ) = Fri Mar 10 02:47:57 2006