init

Launching Linux from Busybox (pivot_root or switch_root, or ? )

耗尽温柔 提交于 2019-12-04 09:52:55
On a beaglebone hardware, I want to start on a partition with a minimalist busybox system (/dev/mmcblk0p2), run some checks on the 2 other partitions (/dev/mmcblk0p5 & /dev/mmcblk0p6) containing more complete Linux systems (Angström), then start on one or the other of the 2 Linux systems based on those tests. The problem is that I cannot find how to start another system correctly from busybox. What I did: From the (perfectly working) busybox system: export PATH=/bin:/sbin:/usr/bin:/usr/sbin mount -t sysfs sysfs /sys mkdir -p /dev/pts mount -t devpts devpts /dev/pts mount /dev/mmcblk0p5 /mnt

Switch user in a init script?

不羁岁月 提交于 2019-12-04 09:30:57
问题 Here's my Init script which I have at my Ubuntu workstation. I need to run a command as another user than root, but I just can't get my head around how it should be done. Neither sudo -u or su newuser seems to work. The script: respawn console none start on runlevel [2345] stop on runlevel [06] script su "anotherUser" -c ./myCommand end script 回答1: I use this: su -l $MUSER -c "myCommand args..." Update : Since there is interest in this answer, I explain the way I use it here. We run servers

Python multi-inheritance, __init__

你。 提交于 2019-12-04 07:50:09
问题 Regarding multiple parent inheritance, when I call the super . __init__ , why doesn't parent2's __init__ function get called? Thanks. class parent(object): var1=1 var2=2 def __init__(self,x=1,y=2): self.var1=x self.var2=y class parent2(object): var4=11 var5=12 def __init__(self,x=3,y=4): self.var4=x self.var5=y def parprint(self): print self.var4 print self.var5 class child(parent, parent2): var3=5 def __init__(self,x,y): super(child, self).__init__(x,y) childobject = child(9,10) print

What is the use of the init() usage in JavaScript?

随声附和 提交于 2019-12-04 07:26:13
问题 So, I just wanna know if anybody knows the particular meaning and usage of the init() statement in JavaScript, never really knew, kind of a newb. 回答1: JavaScript doesn't have a built-in init() function, that is, it's not a part of the language. But it's not uncommon (in a lot of languages) for individual programmers to create their own init() function for initialisation stuff. A particular init() function may be used to initialise the whole webpage, in which case it would probably be called

Swift Generic constraints in init

大憨熊 提交于 2019-12-04 06:06:37
I have generic and I want to be able to initialize it with specific constrains. The constraints are only there for initialization. The rest of the class doesn't care. Here is a simplified example: struct Generic<T> { let compare: (T, T) -> Bool init<T: Equatable>(data: [T]) { let handler: (T, T) -> Bool = { $0 == $1 } compare = handler insert(data) } init(compareHandler: (T, T) -> Bool, data[T]) { compare = self.compareHandler insert(data) } } You can see there's two initializers. The second one obviously works fine. However, in the first one the local type T is mismatched with the struct's

Can I have two init functions in a python class?

↘锁芯ラ 提交于 2019-12-04 05:39:34
I'm porting some geolocation java code from http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates#Java (shown below) to python. It can be initialized using two functions (fromDegrees or fromRadians). I thought I could do something like class geoLocation: _radLat = 0 _radLong = 0 _degLat = 0 _degLong = 0 def fromDegrees(lat, long): #set _radLat, _radLong, _degLat, _degLong def fromRadians(lat, long): #set _radLat, _radLong, _degLat, _degLong ... But that does not seem optimal since I set the values for _radLat, _radLong, _degLat and _degLong twice. Can I define two init functions? What's

Python, __init__ and self confusion

霸气de小男生 提交于 2019-12-04 04:05:52
问题 Alright, so I was taking a look at some source when I came across this: >>> def __parse(self, filename): ... "parse ID3v1.0 tags from MP3 file" ... self.clear() ... try: ... fsock = open(filename, "rb", 0) ... try: ... fsock.seek(-128, 2) ... tagdata = fsock.read(128) ... finally: ... fsock.close() ... if tagdata[:3] == 'TAG': ... for tag, (start, end, parseFunc) in self.tagDataMap.items(): ... self[tag] = parseFunc(tagdata[start:end]) ... except IOError: ... pass ... So, I decided to test it

If I do nothing in -init, is it the same as just calling [MyClass alloc]?

╄→гoц情女王★ 提交于 2019-12-04 02:55:19
If I have an NSObject subclass which either has no -init method or simply does nothing in -init , is there any difference between an instance created these two ways: MyClass *instance = [MyClass alloc]; MyClass *instance = [[MyClass alloc] init]; By "does nothing in -init " I mean - (id)init { self = [super init]; if (self) { } return self; } Since NSObject 's -init method itself does nothing, I can't see there being any difference, but of course the advice is that you must call -init to properly prepare an object. Here's the snippet from NSObject 's -init method which got me wondering about

What is causing “unbound method __init__() must be called with instance as first argument” from this Python code?

爱⌒轻易说出口 提交于 2019-12-04 02:30:35
I have this class: from threading import Thread import time class Timer(Thread): def __init__(self, interval, function, *args, **kwargs): Thread.__init__() self.interval = interval self.function = function self.args = args self.kwargs = kwargs self.start() def run(self): time.sleep(self.interval) return self.function(*self.args, **self.kwargs) and am calling it with this script: import timer def hello(): print \"hello, world t = timer.Timer(1.0, hello) t.run() and get this error and I can't figure out why: unbound method __init__() must be called with instance as first argument You are doing:

Java applet setSize not accurate, window too large

感情迁移 提交于 2019-12-04 02:20:09
问题 I have a Java applet that J am trying to to set to 480, 800 using setSize but the window comes up 487,850 for some reason. here is the code where it is set. public void init() { setSize(480,800); setBackground(Color.BLUE); setFocusable(true); addMouseListener(this); addKeyListener(this); Frame frame = (Frame) this.getParent().getParent(); frame.setTitle("SwingBall"); try { base = getDocumentBase(); } catch (Exception e) { // TODO: handle exception } } There is no other mention of setting size