Code Monkey home page Code Monkey logo

Comments (15)

gotlium avatar gotlium commented on August 15, 2024

Идея хорошая, но что лучше? На автомате по текущему SHELL или же опцией -s zshrc

from ahc.

index0h avatar index0h commented on August 15, 2024

Я думаю лучше определять текущий shell автоматом, далее задать вопрос на подтверждение, в случае -s zshrc - не делать данную проверку

from ahc.

gotlium avatar gotlium commented on August 15, 2024

Теперь доступна опция -s shell, и там уже автоматом в домашнюю директорию поставится zshrc или bashrc. В зависимости от переменной окружения.
Опция -s bashrc - удалена.
Попробуйте на Вашей машине.

from ahc.

index0h avatar index0h commented on August 15, 2024

Есть проблема в том, что хоть shell и определяется корректно, но вместо создания .zshrc заменяется .bashrc

~ root@localhost > echo $SHELL
/bin/zsh
~ root@localhost > ahc -m install -s shell
~ root@localhost > 
~ root@localhost > find ~ -name ".zshrc"
~ root@localhost > 
~ root@localhost > cat .bashrc 
# http://brokenbrake.biz/2010/08/03/.zshrc
.........

from ahc.

gotlium avatar gotlium commented on August 15, 2024

а можешь попробовать запустить python в консоли и набрать:
import os
print 'python env shell: %s' % os.getenv('SHELL')
os.system('echo $SHELL')
и тоже самое сделать создав файл:
test.py с таким же содержанием. а после выполнить python test.py
и stdout в студию)

from ahc.

index0h avatar index0h commented on August 15, 2024

Да, вот вывод.

~ root@localhost > python
Python 2.7.3 (default, Apr 20 2012, 22:44:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print 'python env shell: %s' % os.getenv('SHELL')
python env shell: /bin/zsh
>>> os.system('echo $SHELL')
/bin/zsh
0
>>>
~ root@localhost > python ./test.py 
python env shell: /bin/zsh
/bin/zsh
~ root@localhost > 

from ahc.

gotlium avatar gotlium commented on August 15, 2024

если в файле modules/install.py на 28 строчке изменить .bashrc на .zshrc - измениться ситуация? Это моя опечатка. Если да, то закомичу

from ahc.

index0h avatar index0h commented on August 15, 2024

нет, похоже проблема в чем то другом, так как все ровно создается .bashrc.
добавил вывод после 28-ой строчки

print 'python env shell: %s' % os.getenv('SHELL')

но текст так в консоль не вывелся, хотя после 22-ой тоже не выводится.

Рекомендую в этом пункте использовать switch-case, так как есть еще несколько популярных интерпретаторов, а дефолтный выбрать - баш

from ahc.

gotlium avatar gotlium commented on August 15, 2024

правильно там откешированно все. выполни:

find /usr/lib/ahc ( -name '.pyc' -or -name '.pyo' ) -delete

from ahc.

index0h avatar index0h commented on August 15, 2024

хм, сделал, но проблема осталась:

/usr/src/ahc root@localhost > echo $SHELL
/bin/zsh
/usr/src/ahc root@localhost > mv ~/.bashrc ~/bashrc_backup
/usr/src/ahc root@localhost > mv ~/.zshrc ~/zshrc_backup
/usr/src/ahc root@localhost > find /usr/lib/ahc -name '.pyc' -or -name '.pyo'  -delete
/usr/src/ahc root@localhost > ahc -m install -s shell
/usr/src/ahc root@localhost > find ~ -name '.bashrc'
/root/.bashrc
/usr/src/ahc root@localhost > find ~ -name '.zshrc' 
/usr/src/ahc root@localhost > 

from ahc.

gotlium avatar gotlium commented on August 15, 2024

Будучи в своей оболочке:
$ ahc -m install -s shell

Shell config for "/bin/bash" successfully installed.

И под zsh:
~ root@gotlium > head -2 ~/.zshrc

TESTING

http://brokenbrake.biz/2010/08/03/.zshrc

~ root@gotlium > ahc -m install -s shell

Shell config for "/bin/zsh" successfully installed.

~ root@gotlium > head -2 ~/.zshrc

http://brokenbrake.biz/2010/08/03/.zshrc

Метод изменился на подобное:

def shell(self):
    home = os.getenv('HOME')
    shell = os.getenv('SHELL')
    if shell.find('/bash') != -1:
        configuration = getTemplate('bashrc')
        filename = '%s/.bashrc' % home
    elif shell.find('/zsh') != -1:
        configuration = getTemplate('zshrc')
        filename = '%s/.zshrc' % home
    else:
        error_message('Sorry, your shell not supported!')
    if fileExists(filename):
        backFile(filename)
    putFile(filename, configuration)
    info_message('Shell config for "%s" successfully installed.' % shell)

Только осторожнее с отступами

from ahc.

gotlium avatar gotlium commented on August 15, 2024

Там условия группировать надо. Попробуй тогда просто pyo файлы удалить:
$ find /usr/lib/ahc -name '.pyo' -delete

from ahc.

index0h avatar index0h commented on August 15, 2024

Не помогло((. Странно, что info_message('Shell config for "%s" successfully installed.' % shell) на 35-ой строчке не отрабатывает.

/usr/src/ahc root@localhost > head -35 modules/install.py         
__author__ = 'gotlium'

import MySQLdb
import getpass, pwd
import os

from libraries.helpers import *
from libraries.apache import CertificateGenerator

class Install(object):

    def __init__(self, base):
        self.base = base
        self.methods = ('service',)

    def certs(self):
        cert = CertificateGenerator(self.base)
        if cert.createDatabase():
            info_message('"Apache SSL Certs Protection" was successfully installed.')

    def shell(self):
        home = os.getenv('HOME')
        shell = os.getenv('SHELL')
        if shell.find('/bash') != -1:
            configuration = getTemplate('bashrc')
            filename = '%s/.bashrc' % home
        elif shell.find('/zsh') != -1:
            configuration = getTemplate('zshrc')
            filename = '%s/.zshrc' % home
        else:
            error_message('Sorry, your shell not supported!')
        if fileExists(filename):
            backFile(filename)
        putFile(filename, configuration)
        info_message('Shell config for "%s" successfully installed.' % shell)
/usr/src/ahc root@localhost > find ~ -name '.zshrc'      
/usr/src/ahc root@localhost > find /usr/lib/ahc -name '.pyc' -delete
/usr/src/ahc root@localhost > find /usr/lib/ahc -name '.pyo' -delete
/usr/src/ahc root@localhost > ahc -m install -s shell               
/usr/src/ahc root@localhost > find ~ -name '.zshrc'                 
/usr/src/ahc root@localhost > 

from ahc.

gotlium avatar gotlium commented on August 15, 2024

Давай попробуем удалить проект и снова склонировать его. Уж больно странно все это. Такого поведения не должно быть! Только забэкапь конфиг. Учти что это символьная ссылка на /usr/lib/ahc/configs.cfg

$ rm -rf /usr/src/ahc/
$ cd /usr/src/ && git clone https://github.com/gotlium/ahc.git
$ cd ./ahc/
$ make remove
$ make install

from ahc.

index0h avatar index0h commented on August 15, 2024

Отрабатывает, пасиб

from ahc.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.